booboom
booboom
  • 发布:2020-09-25 15:49
  • 更新:2022-05-23 23:44
  • 阅读:2434

【报Bug】微信小程序编辑器运行时报错: non-array objects must have a [Symbol.iterator]() method.

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 10.15.6

第三方开发者工具版本号: 1.03.2009140

基础库版本号: 2.13.0

项目创建方式: CLI

CLI版本号: 2.0.0-28920200907001

示例代码:
<template>  
  <view class="content">  

    <view class="nav-icons">  
      <view class="icon-item" v-for="(item, index) in arr" :key="item" @click="goClassify(index + 1)">  
        <view class="title">美食{{item}}</view>  
      </view>  
    </view>  

  </view>  
</template>  

<script>  
export default {  
  data() {  
    return {  
      arr: [1,2,3,4,5]  
    }  
  },  

  methods: {  
    goClassify(id) {  
      uni.navigateTo({  
        url: `/pages/classify/index?id=${id}`  
      })  
    },  

  },  
}  
</script>

pages.json

{  
    "pages": [  
        {  
            "path": "pages/index/index",  
      "style": {  
                "app-plus":{  
                    "scrollIndicator": "none",  
                    "titleNView": false  
        }  
            }  
        },  
        {  
            "path": "pages/classify/index"  
        }  
    ],  
    "globalStyle": {  
        "navigationBarTextStyle": "black",  
        "navigationBarTitleText": "123123",  
        "navigationBarBackgroundColor": "#FFFFFF",  
    "backgroundColor": "#FFFFFF",  
    "h5": {  
      "titleNView": false  
    }  
  }  
}

操作步骤:

编译时或者跳转页面路由时都有几率出现。

预期结果:

希望能捕捉到错误位置,或如何避免该类错误。

实际结果:

无法定位错误,也无法处理。

bug描述:

uniapp开发时编译成微信小程序时并在小程序开发工具运行时,时而会出现:

VM1879:1 TypeError: Invalid attempt to destructure non-iterable instance.  
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.  
    at VM1885 WAService.js:2  
    at o (VM1885 WAService.js:2)  
    at i.value (VM1885 WAService.js:2)  
    at VM1885 WAService.js:2  
    at r (VM1885 WAService.js:2)  
    at VM1885 WAService.js:2  
    at VM1885 WAService.js:2  
    at i (VM1883 asdebug.js:1)  
    at c (VM1883 asdebug.js:1)  
    at VM1883 asdebug.js:1

项目代码已经全部移除,只保留了一个跳转页面。

这样的报错,无法定位问题。

2020-09-25 15:49 负责人:DCloud_UNI_GSQ 分享
已邀请:
2***@qq.com

2***@qq.com

<view class="icon-item" v-for="(item, index) in arr" :key="index" @click="goClassify(index + 1)">

应该是 :key不对

要回复问题请先登录注册