taro icon indicating copy to clipboard operation
taro copied to clipboard

@taro/taro-weapp 报错

Open Dithub2016 opened this issue 8 years ago • 12 comments

问题描述 位于 node_modules/@tarojs/taro-weapp/dist/taro-weapp.js 文件的 1262 行代码,对一个 Object 执行了 map 方法,导致报错.

复现步骤 不太清楚,代码大概长这样, 删掉 {res.map.... 代码块就好了,

render() {
  const {allList = [], onlineList = [], offineList = []} = this.state;
  const scrolls = [allList, onlineList, offlineList];
  return (
    <View>
      {scrolls.map((res, resIndex) => {
          return (
            <ScrollView
              scrollY
              onScrolltolower={this.onGetMore.bind(this)}
            >
              {res.map(item => {
                return (
                  <View className="order-list-item___wrap" key={item.id}>
                    <OrderListItem />
                  </View>
                );
              })}
            </ScrollView>
          );
        })}
    </View>
  )
}

期望行为 bug fixed

报错信息 以下为报错信息

VM9396:1 thirdScriptError
inData.map is not a function;at pages/store/orderList/index page lifeCycleMethod onLoad function
TypeError: inData.map is not a function
    at http://127.0.0.1:29645/appservice/npm/@tarojs/taro-weapp/dist/index.js:1260:31
    at Array.map (<anonymous>)
    at dynamicRecursive (http://127.0.0.1:29645/appservice/npm/@tarojs/taro-weapp/dist/index.js:1250:16)
    at http://127.0.0.1:29645/appservice/npm/@tarojs/taro-weapp/dist/index.js:1278:16
    at Array.map (<anonymous>)
    at http://127.0.0.1:29645/appservice/npm/@tarojs/taro-weapp/dist/index.js:1277:29
    at Array.map (<anonymous>)
    at dynamicRecursive (http://127.0.0.1:29645/appservice/npm/@tarojs/taro-weapp/dist/index.js:1250:16)
    at $45b1b249 (http://127.0.0.1:29645/appservice/pages/store/orderList/index.js:73:65)
    at http://127.0.0.1:29645/appservice/npm/@tarojs/taro-weapp/dist/index.js:2726:23

具体情况 image

系统信息

  • 操作系统: windows 7
  • Taro 版本 v0.0.68
  • Node.js 版本 v8.11.2

补充信息 我怎么记得,之前是没问题的,可能是记错了

Dithub2016 avatar Jul 10 '18 09:07 Dithub2016

补充一下,删除 OrderListItem 自定义组件的使用就好了,

Dithub2016 avatar Jul 10 '18 09:07 Dithub2016

再补充一下,回退到 taro v0.0.67 没有问题

Dithub2016 avatar Jul 10 '18 09:07 Dithub2016

constructor里面给 state 一个初始值

zacksleo avatar Jul 14 '18 10:07 zacksleo

在 contructor 里是存在 state 的初始值的, allList, onlineList, offlineList 皆为 []

Dithub2016 avatar Jul 16 '18 02:07 Dithub2016

麻烦把报错代码和复现代码对应起来,你报错和代码不是一回事没有办法 debug

yuche avatar Jul 16 '18 02:07 yuche

不是一回事? 第一层 map scrolls 数据, image indata 为 数组,没异常,这也正是 ScrollView 的类名, 嵌套的第二层 map ,indata 是一个 Object ,导致报错的发生 image

Dithub2016 avatar Jul 16 '18 09:07 Dithub2016

我也出现了一样的问题。 1531735042748 上面的代码只要把map中的<View>换成一个普通的<View>Hello world</View>就没问题,报的错误也是inData.map is not a function

ghost avatar Jul 16 '18 10:07 ghost

请问到 0.0.69 有问题吗?

yuche avatar Jul 16 '18 10:07 yuche

123 版本号:0.0.69 macos

ghost avatar Jul 16 '18 10:07 ghost

补充一下:在node:8.8.0和node:10.6.0,都测试过,报一样的错误。

ghost avatar Jul 16 '18 10:07 ghost

已解决,升级到0.0.70,node 版本10.6.0

ghost avatar Jul 17 '18 03:07 ghost

这边 node v8.11.2 以及 v8.11.3 还有 v10.6.0 , 在 taro v0.0.70 版本该问题继续存在 @clarktang 在 node v8.XX.X 版本问题有继续复现吗

在双层 map 遍历出 自定义组件时依然报错,但去除第一层 map 后就正常了

Dithub2016 avatar Jul 18 '18 01:07 Dithub2016