我有一个使用vue的应用程序.js.我在一个对象数组中使用v-for生成一个结果列表.
this.results.displayed[key] = _.extend({}, this.results.displayed[key], detail.items);
但问题是,当我像上面说的那样使用extend时,它不会更新视图.
我有一个使用vue的应用程序.js.我在一个对象数组中使用v-for生成一个结果列表.
this.results.displayed[key] = _.extend({}, this.results.displayed[key], detail.items);
但问题是,当我像上面说的那样使用extend时,它不会更新视图.
当您按数组索引设置新项时,Vue无法检测到更改.要解决这个问题,可以使用Vue添加到数组中的$set()
方法.
var newObject = _.extend({}, this.results.displayed[key], detail.items);
this.results.displayed.$set(key, newObject);
更多信息here.