0
votes

I used in mapGetters for get param from store,

 computed: {
    ...mapGetters("agent",["getConfig"]),
}

It is working well, But it do error:

[Vue warn]: Computed property "getConfig" was assigned to but it has no setter.

I tried do it with Get and Set:

computed: {
getConfig: {
    get: () => this.$state.getters.getConfig,
    set: (value) => this.$state.commit('setConfiguration', value ) }}

But I have error:

vue.runtime.esm.js:620 [Vue warn]: Error in getter for watcher "getConfig": "TypeError: Cannot read property '$state' of undefined"

What is the correct syntax to make Get and Set for "GetConfig" in computed?

1

1 Answers

2
votes

The context of this is lost in arrow functions.

So just change to:

 get: function() { 
   return this.$state.getters.getConfig
 },
 set: function(value) {
   this.$state.commit('setConfiguration', value ) 
 }