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

flat,startsWith等编译不了,提示is not a function #5246

Closed
spencer17x opened this issue Jan 5, 2020 · 4 comments
Closed

flat,startsWith等编译不了,提示is not a function #5246

spencer17x opened this issue Jan 5, 2020 · 4 comments
Assignees

Comments

@spencer17x
Copy link
Contributor

spencer17x commented Jan 5, 2020

无法识别es2019等的语法,配置了babel无效,貌似taro中的babel版本是6?
尝试引了babel-polyfill等的方法,发现babel-polyfill里面没有flat,只有flatten,没敢用。。
可以麻烦贴个配置吗?我试过好几次都不行....配置都无效....

现在是config/index配置如下:

plugins: {
		babel: {
			sourceMap: true,
			presets: [
				['env', {
					modules: false,
					useBuiltIns: true,
					debug: false
				}]
			],
			plugins: [
				'transform-decorators-legacy',
				'transform-class-properties',
				'transform-object-rest-spread'
			]
		},

然后在 app.tsx 中
import '@tarojs/async-await';
import 'babel-polyfill';

不知道这样有效与否,而且 polyfill 也是只有 stars-with这样,没 flat...

官方可以给个配置不,自己配置都没成功....

版本:
👽 Taro v1.3.34

Taro CLI 1.3.34 environment info:
System:
OS: macOS 10.15.2
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
npmPackages:
@tarojs/async-await: 1.3.34 => 1.3.34
@tarojs/components: 1.3.34 => 1.3.34
@tarojs/mobx: 1.3.34 => 1.3.34
@tarojs/mobx-h5: 1.3.34 => 1.3.34
@tarojs/mobx-rn: 1.3.34 => 1.3.34
@tarojs/plugin-babel: 1.3.34 => 1.3.34
@tarojs/plugin-csso: 1.3.34 => 1.3.34
@tarojs/plugin-stylus: 1.3.34 => 1.3.34
@tarojs/plugin-uglifyjs: 1.3.34 => 1.3.34
@tarojs/rn-runner: 1.3.34 => 1.3.34
@tarojs/router: 1.3.34 => 1.3.34
@tarojs/taro: 1.3.34 => 1.3.34
@tarojs/taro-alipay: 1.3.34 => 1.3.34
@tarojs/taro-h5: 1.3.34 => 1.3.34
@tarojs/taro-swan: 1.3.34 => 1.3.34
@tarojs/taro-tt: 1.3.34 => 1.3.34
@tarojs/taro-weapp: 1.3.34 => 1.3.34
@tarojs/webpack-runner: 1.3.34 => 1.3.34
eslint-config-taro: 1.3.34 => 1.3.34
eslint-plugin-taro: 1.3.34 => 1.3.34
nerv-devtools: ^1.5.6 => 1.5.6
nervjs: ^1.5.6 => 1.5.6
stylelint-config-taro-rn: 1.3.34 => 1.3.34
stylelint-taro-rn: 1.3.34 => 1.3.34

@taro-bot
Copy link

taro-bot bot commented Jan 5, 2020

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Jan 5, 2020

欢迎提交 Issue~

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

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

Good luck and happy coding~

@luckyadam
Copy link
Member

@spencer17x
Copy link
Contributor Author

那是在 app .jsx全局import一次就可以了吗?还是必须得相应的页面或组件中每次都import?

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

3 participants