小编mcm*_*mik的帖子

我可以在Vue实例方法中使用mapMutations中使用"this"吗?

我想将Vuex突变设置如下:

export default {
    props: {
        store: String
    },
    methods: {
        ...mapMutations({
            changeModel: `${this.store}/changeModel`
        })
    }
}
Run Code Online (Sandbox Code Playgroud)

但我抓住了这个错误:

未捕获的TypeError:无法读取未定义的属性"store"

如何在模块变异名称中正确使用道具

我想要映射this.$store.commit('form1/changeModel'),form1道具设置的地方.

javascript this vue.js vuex vuex-modules

11
推荐指数
1
解决办法
735
查看次数

标签 统计

javascript ×1

this ×1

vue.js ×1

vuex ×1

vuex-modules ×1