vue在create中获取数据后更改数据

getData() {

      this.$ajax.get('/api/commodityCategory/list')

        .then(response => {

          let list = response.data;

          this.tag1 = list;

          for(let i = 0;i < this.tag1.length;i++){

            this.tag1[i].visible1 = 'false';

          }

          console.log(this.tag1);

          console.log(response.data.data);

        })

        .catch(function(response) {

          console.log(response);

        });

          

    }

在create中执行getData方法后数据中的visible1并没有改变,怎么解决


DIEA
浏览 1806回答 1
1回答

萧十郎

数组更新检测机制修改你的for循环this.tag1&nbsp;=&nbsp;this.tag1.map(v&nbsp;=>&nbsp;Object.assign({},&nbsp;v,&nbsp;{visible1:&nbsp;'false'}))
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript