这个错误是因为使用了es7语法,需要babel转换
注意:不建议使用babel-polyfill
,因为这个太大了
安装:
npm install --save-dev @babel/plugin-transform-runtime
npm install --save @babel/runtime
webpack.config.js
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
...
plugins: ['@babel/plugin-transform-runtime']
}
}
]
}
]
}