Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davestewart/vue-enums
Easily use TypeScript enums in Vue SFC templates
https://github.com/davestewart/vue-enums
Last synced: 30 days ago
JSON representation
Easily use TypeScript enums in Vue SFC templates
- Host: GitHub
- URL: https://github.com/davestewart/vue-enums
- Owner: davestewart
- License: mit
- Created: 2019-09-18T15:08:18.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-18T15:19:46.000Z (about 5 years ago)
- Last Synced: 2024-10-08T16:30:00.922Z (about 1 month ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vue Enums
> Easily use TypeScript enums in Vue SFC templates
## Installation
Install and configure in your `main` file:
```js
import Vue from 'vue'
import enums from 'vue-enums'// use enums directly in template
Vue.use(enums)
```Alternatively, define enums under a namespace:
```js
// in templates, use {{ $enums.YourEnum }}
Vue.use(enums, { namespace: '$enums'} )
```## Usage
Define enums:
```ts
enum Status {
accepted = 1,
declined = 2,
}export default Status
```Use in component:
```vue
You have been accepted!
import Status from 'status'
export default {
enums: {
Status,
},data () {
return {
state: Status.accepted
}
}
}```