经过审查,发现是这段代码出了问题

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);
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐