1.何时用计算属性 何时用监听属性
watch: {
firstName: function (val) {
this.fullName = val + ' ' + this.lastName
},
lastName: function (val) {
this.fullName = this.firstName + ' ' + val
}
}
computed: {
fullName: function () {
return this.firstName + ' ' + this.lastName
}
}
网友评论