报错原因:当你在页面中使用计v-model去改变计算属性的值(我是在input组件中使用v-model和vuex的state中的数据进行关联),使用默认的getter是会报错的,需要提供一个setter。
computed: {
inputVal: {
// getter
get() {
return this.$store.state.inputVal
},
set(newValue) {
this.$store.state.inputVal = newValue
}
}
}
报错原因:当你在页面中使用计v-model去改变计算属性的值(我是在input组件中使用v-model和vuex的state中的数据进行关联),使用默认的getter是会报错的,需要提供一个setter。
computed: {
inputVal: {
// getter
get() {
return this.$store.state.inputVal
},
set(newValue) {
this.$store.state.inputVal = newValue
}
}
}