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

Babel 7 Webpack 3 vux 编译后【ES 6 函数 参数 默认值】就不能转译了。 #72

Open
stuartZhang opened this issue Nov 22, 2018 · 5 comments

Comments

@stuartZhang
Copy link

VUX version
2.9.2

OS/Browsers version
Chrome

Vue version
2.5.17

Code
这是我的 .babelrc 文件的配置

{
"presets": [
[
"@babel/env",
{
"useBuiltIns": "usage",
"modules": false,
"targets": {
"browsers": [
"android >= 4",
"safari >= 5",
"ios_saf >= 4",
"> 1%",
"last 4 versions",
"not ie <= 8"
]
}
}
]
],
"plugins": [
"transform-vue-jsx",
"transform-es2015-parameters",
"@babel/plugin-transform-parameters",
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
],
"env": {
"test": {
"presets": [
"@babel/preset-env"
],
"plugins": [
"transform-vue-jsx",
"istanbul",
"@babel/plugin-transform-parameters",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
]
}
}
}
Steps to reproduce
@babel/core 版本是 7.0.0
vux-loader 版本是 1.2.9
webpack 版本是 3.6.0

在 babel 编译之后,在src\plugins\alert\index.js 文件内 第12行 show (options = {}) { 就不能被 转译了。于是,在手机上,就会报一个错误“Unexpected token =”。

但是,非常奇怪的是,在我自己里 业务代码内的【 ES6 函数默认参数】 就能够被 正确地 转译。

能不能给一些 问题可能 出在哪里的提示呀?

What is Expected?
在src\plugins\alert\index.js 文件内 第12行 show (options = {}) { 就能被 转译。

What is actually happening?
在 babel 编译之后,在src\plugins\alert\index.js 文件内 第12行 show (options = {}) { 就不能被 转译了。于是,在手机上,就会报一个错误“Unexpected token =”。

@yaoshining
Copy link

请问你的问题解决了么,我也遇到了同样的问题

@stuartZhang
Copy link
Author

stuartZhang commented Jan 25, 2019 via email

@yaoshining
Copy link

太感谢了,这问题困扰了我三天终于解决了,应该给你发个大红包

@stuartZhang
Copy link
Author

stuartZhang commented Jan 25, 2019 via email

@yaoshining
Copy link

我们单聊吧,qq号发你邮箱了

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

2 participants