組件的數組索引的數據我需要更新我的VueJS組件陣列的一些數據,通過v-for
渲染爲一個列表中的模板。沒有更新
當我更新整個數組時,我發現列表在DOM中更新。但是,如果我僅更新索引,則列表不會更新。
這裏有兩個相關的方法:
methods: {
loadOnlyOneIndex: function() {
this.data[0] = {
title: 'Hello error',
slug: 'hello',
desc: 'will not work'
};
},
loadEverything: function() {
this.data = [{
title: 'Hello new title',
slug: 'hello',
desc: 'this will work'
}, {
title: 'Hello new title 2 !',
slug: 'hello2',
desc: 'really work'
}];
}
}
https://vuejs.org/v2/guide/list.html#Caveats – thanksd
謝謝,這是真正棘手看到對象更新,但不認爲... – moabi