Whenever I try to combine a Vuex local computed object with get/set and store mappings, I encounter a syntax error.
In the Vuex documentation, it shows how you can map your store methods using the object spread operator like this:
computed: {
localComputed () { /* ... */ },
// mix this into the outer object with the object spread operator
...mapState({
// ...
})
}
https://vuex.vuejs.org/en/state.html##object-spread-operator
You can also create computed setters like so:
computed: {
fullName: {
// getter
get: function () {
return this.firstName + ' ' + this.lastName
},
// setter
set: function (newValue) {
var names = newValue.split(' ')
this.firstName = names[0]
this.lastName = names[names.length - 1]
}
}
}
https://v2.vuejs.org/v2/guide/computed.html#Computed-Setter
I've tried creating either a computed object with get/set or using mapState/mapGetters separately, but combining them results in a syntax error (specifically, it says: expected function name after the function declarations).
computed: {
localComputed () {
localMethod: {
get: function () {
// retrieve
},
set: function (newContent) {
// set
}
}
}, ...mapState([
]), ...mapGetters([])
}
Is there a way to effectively combine these two methods?