我将很多数据都push到data中的一个字段中了:
data() {
return {
networkInterfacesConfig: [],
method() 其中一个
for (let NetworkInterfaceName in networkInterfacesConfigJson) {
let NetworkInterfaceInfo = networkInterfacesConfigJson[NetworkInterfaceName];
this.networkInterfacesConfig.push(NetworkInterfaceInfo);
};
按理来讲 this.networkInterfacesConfig
应该是数组,但是当我用另外一个 method 调用的时候,forEach
、for...in
、for...of
都无法处理,会被直接跳过。使用JSON.stringify
后就直接变成空的了。
执行console.log(this.networkInterfacesConfig)
发现是这种东西:
原型是数组,还有长度,但是js原生的遍历语句都不能使用,直接掉这个玩意的.length
也是0
该怎么办?
用
this.networkInterfacesConfig.slice()
返回的数组试试