小编Ily*_*rov的帖子

vue.js:当数组更改时,v-for 不会重新渲染内容

为什么 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)

javascript vue.js

3
推荐指数
1
解决办法
8129
查看次数

标签 统计

javascript ×1

vue.js ×1