我正在使用vue-cli构建一个javascript Web应用程序。
我注意到已编译的javascript代码中有一些const
个关键字。浏览器说SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode
编译后的代码如下:
"use strict";
eval("/*blabla*/ const xxx ...");
我的babelrc:
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-runtime"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["istanbul"]
}
}
}
babel-loader配置文件如下:
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
},