vuex-class用法
生活随笔
收集整理的這篇文章主要介紹了
vuex-class用法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
vuex-class可以包裝vuex的寫法,使代碼簡化
Installation
$?npm?install?--save?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')@Componentexport?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?quxcreated?()?{this.stateFoo?//?->?store.state.foothis.stateBar?//?->?store.state.barthis.getterFoo?//?->?store.getters.foothis.actionFoo({?value:?true?})?//?->?store.dispatch('foo',?{?value:?true?})this.mutationFoo({?value:?true?})?//?->?store.commit('foo',?{?value:?true?})this.moduleGetterFoo?//?->?store.getters['module/foo']}}轉載于:https://www.cnblogs.com/sands/p/11284564.html
總結
以上是生活随笔為你收集整理的vuex-class用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【ngx-ueditor】百度编辑器按下
- 下一篇: vue-property-decorat