有没有一种方法可以通过编程方式更新vue中的data
对象/属性.js?例如,当我的组件加载时,我的数据对象是:
data: function () {
return {
cars: true,
}
}
触发事件后,我希望data
对象看起来像:
data: function () {
return {
cars: true,
planes: true
}
}
我试过:
<script>
module.exports = {
data: function () {
return {
cars: true
}
},
methods: {
click_me: function () {
this.set(this.planes, true);
}
},
props: []
}
</script>
但这给了我this.set is not a function
的误差.有人能帮忙吗?
提前谢谢!