vuex decorator 的使用 #总结



import { createStore } from "vuex";


export const store =  createStore({
  state: {},
  mutations: {},
  actions: {},
  modules: {

  }
});


import {Module, VuexModule, Mutation, Action, getModule} from 'vuex-module-decorators'

import {store} from "@/store";

@Module({
    name: 'loading', dynamic: true, namespaced: true, store,
})
class Loading extends VuexModule {
    _loadingStatus = true;

    @Mutation
    setLoading(loading:boolean) {
        console.log("设置 loaing")
        this._loadingStatus = loading;
    }

    get loadingStatus() {
        return this._loadingStatus;
    }

}
export const loadingModule = getModule(Loading)


import { loadingModule } from '@/store/modules/Loading.ts'
 mounted() {
            setTimeout(()=>{
                loadingModule.setLoading(false)
            },4000)

        }
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 终极编程指南 设计师:CSDN官方博客 返回首页