vue报错undefined is not iterable (cannot read property Symbol(Symbol.iterator))
vue报错undefined is not iterable (cannot read property Symbol(Symbol.iterator))
·
经过审查,发现是这段代码出了问题
this.net1 = this.chartData.net1; // net1,net2,net都是从接口离拿得数据
this.net2 = this.chartData.net2;
this.net = this.chartData.net;
const netTotal = [...this.net1, ...this.net2, ...this.net];//数组合并
let dataYTpl = calculateMaxAndMin(netTotal,0,1);
为什么会报错?
原因是在给netTotal赋值时,net1,net2,net都还没又拿到,此时,net1,net2,net都是undefined.所以再用三点运算符会报错。
解决办法:
this.net1 = this.chartData.net1;
this.net2 = this.chartData.net2;
this.net = this.chartData.net;
let netTotal = [];//数组合并
if(this.net1 && this.net2 && this.net) {
netTotal = [...this.net1, ...this.net2, ...this.net];//数组合并
}
let dataYTpl = calculateMaxAndMin(netTotal,0,1);
更多推荐
已为社区贡献1条内容
所有评论(0)