vue 使用computed报错 .. was assigned to but it has no setter.
文章目录
问题:
<a-radio @change="chooseOther" v-model="tempReadio">其他</a-radio>
computed: {
tempReadio() {
if (this.reasonValue == 7) {
return true;
} else {
return false;
}
},因为我们平时绑定的都是data里面的数据 ,当这个value值是冬天的时候, 严格模式下 此时就会报错
解决方法: 手动添加set 就好了
computed: {
tempReadio: {
get() {
if (this.reasonValue == 7) {
return true;
} else {
return false;
}
},
set(val) {},
},
},vue 官网也有给到解释,关于v-model绑定了vuex 或者 computed的时候,需要自己设置get和set即可
https://vuex.vuejs.org/zh/gui...
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论