在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);
});