• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

undefined is not iterable (cannot read property Symbol(Symbol.iterator)) at _iterableToArray

武飞扬头像
小坚果_
帮助1

undefined is not iterable (cannot read property Symbol(Symbol.iterator)) at _iterableToArray

如果报了这个错误,说明你代码中可能用了 es6中的拓展运算符

我的是这样用的

  1.  
    async loadMore() {
  2.  
    // 获取朋友圈动态
  3.  
    let response = await this.$api.myCollect()
  4.  
    this.arr= [...this.arr, ...response.data.Arr];
  5.  
    }

解决方法是: 做个判断

  1.  
    async loadMore() {
  2.  
    // 获取朋友圈动态
  3.  
    let response = await this.$api.myCollect()
  4.  
     
  5.  
    if (response.code == 200 && response.data.Arr) {
  6.  
    this.arr= [...this.arr, ...response.data.Arr];
  7.  
    }
  8.  
    }

原因是 :

... 这三个点,不能作用在undefined的数据上,所以做个判断就可以了

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgbehcj
系列文章
更多 icon
同类精品
更多 icon
继续加载