用于深结构数据,数据已经被赋值,控制台已经发生变化,但页面数据没有同步更新的情况,此时需要强制刷新页面,方法有两种:
- this.$set
function() {
this.$set(this.form,'name','张三')
// this.$set(object,index,new)
// 参数一: 为想要改变的对象,
// 参数二: 为数组下标或者是对象的属性名称,
// 参数三: 为将要赋的值。
}
- this.$forceUpdate()
function() {
this.form.name= '张三';
this.$forceUpdate();
},
this.$forceUpdate()强制更新方法,作用是触发vue的update方法。