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);
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误通常发生在尝试迭代一个未定义的值时。"Uncaught (in promise) TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))"这个错误给出了一些线索。这意味着你在尝试对一个未定义的值进行迭代操作,而无法使用Symbol(Symbol.iterator)属性。根据提供的信息,可能是在进行懒加载配置时,有一些代码尝试对一个未定义的值进行迭代操作,导致报错。 要解决这个问题,你可以检查你的懒加载配置命令和相应的模块代码。确保你正确地导入和定义了需要迭代的值,并且该值不是未定义的。另外,你也可以检查代码中是否有其他地方尝试对未定义的值进行迭代操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#Object‘的...](https://download.csdn.net/download/weixin_38640984/13612199)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ERROR Error: Uncaught (in promise): TypeError: undefined is not a function](https://blog.csdn.net/zhangbest2009/article/details/116134216)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [angular配置懒加载core.js:14597 ERROR Error: Uncaught (in promise): TypeError: undefined is not a ...](https://blog.csdn.net/zhangbest2009/article/details/102673598)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值