Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list.flatMap is not a function #5215

Closed
raymond-liao opened this issue Dec 30, 2019 · 6 comments
Closed

list.flatMap is not a function #5215

raymond-liao opened this issue Dec 30, 2019 · 6 comments
Assignees

Comments

@raymond-liao
Copy link

问题描述

支付宝小程序在使用数组的 flatMap 方法时报错:
list.flatMap is not a function

但是微信小程序可以正常运行.

复现步骤

直接定义数组使用 flatMap 就可以复现

/**
 * 这段注释后可以贴代码
 * 提供完整可复现的代码和整理好代码格式,有助于我们快速定位问题,节省你我时间
 * 代码提供不全或代码格式混乱的 issues 【有可能会被忽略】
 * 
 * 查看如何插入代码:https://coding.net/help/doc/project/markdown.html#i-5
 */
const list = [1, 2, 3, 4, 5]
const newArr = list.flatMap(i => [i * 2])
console.log(newArr)

期望行为

支付宝小程序也能正常使用 flatMap

报错信息

list.flatMap is not a function

系统信息

👽 Taro v2.0.0-beta.9

Taro CLI 2.0.0-beta.9 environment info:
System:
OS: macOS 10.15.2
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.15.0 - /usr/local/bin/node
npm: 6.13.4 - /usr/local/bin/npm
npmPackages:
@tarojs/components: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/components-qa: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/mini-runner: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/redux: ^1.3.32 => 1.3.33
@tarojs/redux-h5: ^1.3.32 => 1.3.33
@tarojs/router: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro-alipay: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro-h5: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro-qq: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro-quickapp: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro-swan: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro-tt: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/taro-weapp: 2.0.0-beta.9 => 2.0.0-beta.9
@tarojs/webpack-runner: 2.0.0-beta.9 => 2.0.0-beta.9
eslint-config-taro: 2.0.0-beta.9 => 2.0.0-beta.9
eslint-plugin-taro: 2.0.0-beta.9 => 2.0.0-beta.9
nerv-devtools: ^1.5.5 => 1.5.6
nervjs: ^1.5.5 => 1.5.6
stylelint-config-taro-rn: 2.0.0-beta.9 => 2.0.0-beta.9
stylelint-taro-rn: 2.0.0-beta.9 => 2.0.0-beta.9

@taro-bot
Copy link

taro-bot bot commented Dec 30, 2019

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Dec 30, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@raymond-liao
Copy link
Author

我升级了一下 Taro, 不过问题依旧

👽 Taro v2.0.0-beta.12


  Taro CLI 2.0.0-beta.12 environment info:
    System:
      OS: macOS 10.15.2
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 10.15.0 - /usr/local/bin/node
      npm: 6.7.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/components-qa: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/mini-runner: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/redux: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/redux-h5: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/router: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-alipay: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-h5: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-qq: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-quickapp: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-swan: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-tt: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-weapp: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/webpack-runner: 2.0.0-beta.12 => 2.0.0-beta.12 
      eslint-config-taro: 2.0.0-beta.12 => 2.0.0-beta.12 
      eslint-plugin-taro: 2.0.0-beta.12 => 2.0.0-beta.12 
      nerv-devtools: ^1.5.6 => 1.5.6 
      nervjs: ^1.5.6 => 1.5.6 
      stylelint-config-taro-rn: 2.0.0-beta.12 => 2.0.0-beta.12 
      stylelint-taro-rn: 2.0.0-beta.12 => 2.0.0-beta.12 

@raymond-liao
Copy link
Author

尝试升级 nodejs 到 11.15.0, 不过问题依旧

👽 Taro v2.0.0-beta.12


  Taro CLI 2.0.0-beta.12 environment info:
    System:
      OS: macOS 10.15.2
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 11.15.0 - /usr/local/bin/node
      npm: 6.7.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/components-qa: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/mini-runner: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/redux: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/redux-h5: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/router: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-alipay: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-h5: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-qq: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-quickapp: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-swan: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-tt: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/taro-weapp: 2.0.0-beta.12 => 2.0.0-beta.12 
      @tarojs/webpack-runner: 2.0.0-beta.12 => 2.0.0-beta.12 
      eslint-config-taro: 2.0.0-beta.12 => 2.0.0-beta.12 
      eslint-plugin-taro: 2.0.0-beta.12 => 2.0.0-beta.12 
      nerv-devtools: ^1.5.6 => 1.5.6 
      nervjs: ^1.5.6 => 1.5.6 
      stylelint-config-taro-rn: 2.0.0-beta.12 => 2.0.0-beta.12 
      stylelint-taro-rn: 2.0.0-beta.12 => 2.0.0-beta.12 

@Garfield550
Copy link
Collaborator

你缺少 Polyfill,自己给项目添加一个 core-js 吧,注意 Taro 1 和 2 都是用的 Babel 6.

@taro-bot
Copy link

taro-bot bot commented Dec 31, 2019

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants