vuex-class
vuex-class
Binding helpers for Vuex and vue-class-component
Dependencies
Installation
$ npm install --save vuex-class
# or
$ yarn add vuex-class
Example
import Vue from 'vue'
import Component from 'vue-class-component'
import {
State,
Getter,
Action,
Mutation,
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
// If the argument is omitted, use the property name
// for each state/getter/action/mutation type
@State foo
@Getter bar
@Action baz
@Mutation qux
created () {
this.stateFoo // -> store.state.foo
this.stateBar // -> store.state.bar
this.getterFoo // -> store.getters.foo
this.actionFoo({ value: true }) // -> store.dispatch('foo', { value: true })
this.mutationFoo({ value: true }) // -> store.commit('foo', { value: true })
this.moduleGetterFoo // -> store.getters['path/to/module/foo']
}
}
Issue Reporting Guideline
Questions
For general usage question which is not related to vuex-class should be posted to StackOverflow or other Q&A forum. Such questions will be closed without an answer.
Bug Reports
Please make sure to provide minimal and self-contained reproduction when you report a bug. Otherwise the issue will be closed immediately.
License
MIT
Dependencies
@types/mocha: ^5.2.0@types/power-assert: 1.5.0@types/sinon: ^4.3.3es6-promise: ^4.2.4glob: ^7.1.2json-loader: ^0.5.7npm-run-all: ^4.1.3power-assert: ^1.5.0rollup: ^0.58.2rollup-plugin-replace: ^2.0.0sinon: ^5.0.7testem: ^2.4.0ts-loader: ^4.3.0tslint: ^5.10.0tslint-config-ktsn: ^2.1.0typescript: ^2.8.3uglify-js: ^3.3.25vue: ^2.5.16vue-class-component: ^6.2.0vuex: ^3.0.1webpack: ^4.8.3webpack-cli: ^2.1.3webpack-espower-loader: ^2.0.0