vue.js只能监听data中定义的数据 如果新增对象中没有的属性 使用 this.$set(obj, key, value)
/Object.assign(target, sources)
举例
data() {
return {
student: {
name: '张三',
}
}
},
methods: {
setMessage() {
this.$set(this.student, 'age', 15)
console.log(this.student)
}
setMessage2() {
this.student.height= 155
this.student = Object.assign({}, this.student) }
}