|
// Vue.set Vue.set(example1.items, indexOfItem, newValue) |
|
// Array.prototype.splice example1.items.splice(indexOfItem, 1, newValue) |
本文探讨了Vue.js中更新数组元素的两种方法:使用Vue.set()和Array.prototype.splice()。通过实例展示了如何更改数组中的特定项,同时保持视图的响应性。
|
// Vue.set Vue.set(example1.items, indexOfItem, newValue) |
|
// Array.prototype.splice example1.items.splice(indexOfItem, 1, newValue) |

被折叠的 条评论
为什么被折叠?