1、webpack配置文件,增加插件transform-es3-property-literals和transform-es3-member-expression-literals
const webpackdevConfig = {
entry: entry,
output: {
path: path.join(__dirname, 'dist/js'),
filename: '[name].js',
publicPath: '/static/'
},
plugins: [
new webpack.NoErrorsPlugin(),
],
module: {
loaders: [
{
test: /\.js$/, loader: ['babel'], include: [path.join(new_dir, 'src')],
query:{
"presets": ["es2015", "stage-0"],
"plugins" : [
"transform-es3-property-literals",
"transform-es3-member-expression-literals",
]
}
},
{test: /\.scss$/, loaders: ['style', 'css', 'sass'], include: path.join(new_dir, 'src/style')},
{test: /\.(jpg|png)$/, loader: 'url-loader?limit=8192', include: path.join(new_dir, 'src/img')}
]
}
}
2、模块导出不能使用 export default ,改为export { xxx }
3、模块引入使用 import { } from 'xxx'
4、引入es5-shim.min.js和es5-sham.min.js
网友评论