data() {
return {
firstName: '',
lastName: ''
};
},
计算属性
computed: {
fullName: function() {
return this.firstName + ' ' + this.lastName;
}
},
监听属性
watch: {
firstName(newVal) {
this.fullName = newVal + ' ' + this.lastName;
},
lastName(newVal) {
this.fullName = this.firstName + ' ' + newVal;
}
}