Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
}
}
}

```