首页 > 解决方案 > Vue js循环

问题描述

我正在尝试向我的数据添加一个操作,这是代码=

this.array = res.data.data;
        for( i in this.array){
            this.$set(this.array[i], 'action', 
            "<a href='/users/ope/array[i].id'> <v-icon> mdi-account-details-outline </v-icon> </a>"
            ); 
        }

但我有这个错误=

ReferenceError: i is not defined

我做错了什么?

标签: apivue.jsaxiosnuxt.js

解决方案


您错过了使用or定义i变量:letconst

for(let i in this.array){
      ...

表示i索引,如果你想遍历你可以使用的值for(let val of this.array){


推荐阅读