IE不支持Javascript语法以及API的解决方法(使用webpack)

使用Babel编译

安装babel包babel-core``babel-loader``babel-plugin-transform-runtime``babel-polyfill``babel-preset-es2015

webpack.config.js 配置文件

modules.exports = {
    ...
    entry: { name: ['babel-polyfill'], 'path/to/file.js' },  // 在入口文件添加babel-polyfill
    ....
    module: {
        rules: [
            {
                test: /.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            }  // 添加loader
        ]
    }
}

.babelrc 配置文件

{ 
  "presets": [ 
    "es2015" 
  ],
  "plugins": [
    "transform-runtime"
  ] 
}
原文地址:https://www.cnblogs.com/zhangyahan/p/11162020.html