起啥名呢啊 2022-03-07 15:43 采纳率: 46.2%
浏览 68
已结题

vue for循环报错 Duplicate keys detected: 'eth0'. This may cause an update error.

在axios 中使用for循环 ,报错Duplicate keys detected: 'eth0'. This may cause an update error.(检测到重复的密钥:“eth0”。这可能会导致更新错误。)
这一步是加载获取参数. 等我设置完参数.重新调用请求一次的时候,就报错了. 如果鞋子dom里面可以加Key 但在script里面怎么办?

 this.$axios
        .post("/api/config/net_priority_getinfo")
        .then((res) => {
          let data = res.data;
          this.net_priority_getinfo = res.data.netPropertyList;
          console.log(this.net_priority_getinfo);
          var interface1 = data.netPropertyList[0].interface;
          if (interface1 == "eth0") {
            this.youxian = "有线";
          } else if (interface1 == "wlan0") {
            this.youxian = "无线";
          } else if (interface1 == "rmnet_usb0") {
            this.youxian = "5G模块";
          }
          var json1 = { value: "eth0", label: "有线" };
          var json2 = { value: "wlan0", label: "无线" };
          var json3 = { value: "rmnet_usb0", label: "5G模块" };
          for (let i = 0; i < data.num; i++) {
            // console.log(i);
            if (data.netPropertyList[i].interface == "eth0") {
              this.netPriority.push(json1);
            } else if (data.netPropertyList[i].interface == "wlan0") {
              this.netPriority.push(json2);
            } else if (data.netPropertyList[i].interface == "rmnet_usb0") {
              this.netPriority.push(json3);
            }
            // console.log(this.netPriority);
          }
        })
        .catch(() => {
          // console.log(error);
          this.timer = setTimeout(() => {
            this.youxianji();
          }, 60000);
        });
  • 写回答

3条回答 默认 最新

  • 前端互助会 2022-03-07 15:47
    关注

    v-for循环绑定的 key要是唯一的值

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 3月21日
  • 创建了问题 3月7日

悬赏问题

  • ¥30 为什么会失败呢,该如何调整
  • ¥50 如何在不能联网影子模式下的电脑解决usb锁
  • ¥20 服务器redhat5.8网络问题
  • ¥15 如何利用c++ MFC绘制复杂网络多层图
  • ¥20 要做柴油机燃烧室优化 需要保持压缩比不变 请问怎么用AVL fire ESE软件里面的 compensation volume 来使用补偿体积来保持压缩比不变
  • ¥15 python螺旋图像
  • ¥15 算能的sail库的运用
  • ¥15 'Content-Type': 'application/x-www-form-urlencoded' 请教 这种post请求参数,该如何填写??重点是下面那个冒号啊
  • ¥15 找代写python里的jango设计在线书店
  • ¥15 请教如何关于Msg文件解析