为什么 v-for 对更改数组中的某些元素没有反应?
this.test[3] = 3
Run Code Online (Sandbox Code Playgroud)
如果稍后我将调用 push for array,则只有 Vue 重新渲染内容。
this.test[3] = 3;
this.push(4);
Run Code Online (Sandbox Code Playgroud)
示例:https : //codepen.io/anon/pen/debJqK
this.test[3] = 3
Run Code Online (Sandbox Code Playgroud)
this.test[3] = 3;
this.push(4);
Run Code Online (Sandbox Code Playgroud)
var vm = new Vue({
el: "#app",
data: {
test: [1, 2],
},
methods: {
changeVar1: function() {
this.test[3] = 3;
this.test.push(4);
},
changeVar2: function() {
this.test[3] = 3;
}
}
})Run Code Online (Sandbox Code Playgroud)