Monday, 3 September 2018

Can I use "this" in mapMutations spread inside Vue instance methods?

I want to set Vuex mutations as follows:

export default {
    props: {
        store: String
    },
    methods: {
        ...mapMutations({
            changeModel: `${this.store}/changeModel`
        })
    }
}

But I catch the error:

Uncaught TypeError: Cannot read property 'store' of undefined

How do I correctly use props inside the module mutation name?

I want to map this.$store.commit('form1/changeModel'), where form1 is set from props.



from Can I use "this" in mapMutations spread inside Vue instance methods?

No comments:

Post a Comment