vuex-class-decorator
Via vuex-class
Binding helpers for Vuex and vue-class-component
Dependencies
Installation
$ npm i -S vuex-class-decorator
Example
import Vue from 'vue'
import {
State,
Getter,
Action,
Mutation,
GetterSetter,
Component,
namespace
} from 'vuex-class'
const someModule = namespace('path/to/module')
@Component
export class MyComp extends Vue {
@State('foo') stateFoo
@State(state => state.bar) stateBar
@Getter('foo') getterFoo
@Action('foo') actionFoo
@Mutation('foo') mutationFoo
@someModule.Getter('foo') moduleGetterFoo
@GetterSetter('getterKey','setterKey') gsFoo
@State foo
@Getter bar
@Action baz
@Mutation qux
@GetterSetter gsBar
@someModule.GetterSetter name
created () {
this.stateFoo
this.stateBar
this.getterFoo
this.actionFoo({ value: true })
this.mutationFoo({ value: true })
this.moduleGetterFoo
this.gsBar
this.gsBar = 1
this.gsFoo = 'test'
this.name
this.name = 'myname'
}
}
License
MIT