Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用Babel传输默认功能参数_Reactjs_Webpack_Babeljs - Fatal编程技术网

Reactjs 使用Babel传输默认功能参数

Reactjs 使用Babel传输默认功能参数,reactjs,webpack,babeljs,Reactjs,Webpack,Babeljs,我使用的是stage-0Babel预置,能够像类方法一样使用myMethod=()=>{/*code here*/}。由于我开始在stage-0preset中使用此功能,我的项目在iOS

我使用的是
stage-0
Babel预置,能够像类方法一样使用
myMethod=()=>{/*code here*/}
。由于我开始在
stage-0
preset中使用此功能,我的项目在
iOS<10
停止工作,因为输出代码包含默认函数参数
function myFunc(a,b=0){/*code here*/}

这里有没有办法配置Babel将我的代码传输到较低的标准件中

我的网页包babel loader配置:

预设:[“es2015”、“0级”、“反应”]

另外,在我开始使用
stage-0
之前,一切正常,没有
stage-0
,babel loader配置是相同的


UPD: 特别是对于Sulthan,生成错误的代码

Component.prototype.has = function(key, opts, includeDefault = false) {
    var i18n = this.props.i18n;
    // Forth argument is the locale that should be used  
    // We can't use the active one because of the SSR and shared I18n state   
    // Also, we need to observe i18n.locale to detect changes, so this is useful    
    return I18n.has(key, opts, includeDefault, i18n.locale);  
};
错误是:

SyntaxError: 
    Unexpected token '='. 
    Expected a ')' or a ',' after a parameter declaration. /bundle.js:950

我要重复一遍,这部分代码是由Babel生成的,因为它传输了一个显然是i18n库的代码。

好的,伙计们,问题是我的一个节点模块是harmony,我的Babel配置排除了整个节点模块

loader: 'babel-loader',
exclude: /node_modules/,
query: {
  presets: ["es2015", "stage-0", "react"],
  plugins: ["transform-class-properties"]
}

我从配置中删除了
exclude:/node\u modules/,
,现在它工作得很好

默认参数值是
es2015
@Sulthan yea的一部分,因此我要讲的是Babel。您必须添加一个不起作用的代码示例(最小,可编译)。@Sulthan整个包都不起作用。它抛出一个错误
SyntaxError:Unexpected token'='。参数声明后应为“')”或“,”位于
bundle.js:950
,此错误指的是BabelTurn off minify/uglify生成的部分代码,并添加触发错误的代码及其传输版本。这可能是您的代码中的一个bug,如果您不添加它,我们将无法帮助您。