错误例子:
methods: {
A: function () {
return "hello" + this.name;
},
B: function () {
return this.A;
},
}
以上写法使用vue计算属性computed依赖于另一个computed,该写法会在浏览器控制台报错提示Computed property "A" was assigned to but it has no setter
当存在以上依赖关系时,正确的写法是:需提供setter方法
A: {
get: function () {
return "hello" + this.name;
},
set: function (newValue) {
}
},
B: function () {
return this.A;
}