【发布时间】:2018-01-12 23:04:07
【问题描述】:
我正在观察一个值,我计算了另一个值。
类似这样的:
computed: {
modeText: function () {
if(this.mode == 'create')
return 'Create'
else
return 'Edit'
}
},
watch: {
mode(val, old) {
if(val == 'create')
update modeText
else
update modeText
},
},
观察值更新时如何重新计算计算值?
【问题讨论】:
-
计算是反应式的。当 this.mode 改变时,modeText 应该会自动更新。