我有这个store
商店/r2o.ts
import { Module, VuexModule, Mutation } from 'vuex-module-decorators'
import { IR2O } from '~/models/R2O'
@Module({
name: 'r2o',
namespaced: true
})
export default class R2O extends VuexModule {
r2os: Array<IR2O> = []
@Mutation
set(p: Array<IR2O>) {
this.r2os = p
}
}我需要在我的组件中调用这个,我该怎么做呢?
发布于 2021-11-27 15:21:27
如果你想直接做的话
this.$store.commit('r2o/set', [])如果您想使用vuex类
import { namespace } from 'vuex-class'
...
@namespace('r2o').Mutation('set') setR2o: (p: Array<IR20>) => any
myMethod() {
this.setR2o([])
}https://stackoverflow.com/questions/70133367
复制相似问题