use babel-polyfill , it will emulate a complete ES2015+ environment
< H2 >
has been resolved. The solution is as follows < / H2 >
1, change the devtool parameter, in index.js
devtool: 'source-map',
so that we can get specific error messages.
2, if we also use API, in ES6, such as Promise, it will not be supported by IE browsers, so we need to refer to 'babel-polyfill'
webpack.base.conf.js
entry: {
normal: ['babel-polyfill', './src/main.js']
},
main.js
import 'babel-polyfill';
3, refer to whether the plug-ins have been compiled correctly, and the plug-ins I use, such as element-ui,vis, have not been compiled correctly. Change the 'webpack.base.conf.js' file
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('/node_modules/element-ui/src')]
}
//
{
test: /node_modules[\\\/]vis[\\\/].*\.js$/,
loader: 'babel-loader',
query: {
cacheDirectory: true,
presets: [ "babel-preset-es2015" ].map(require.resolve),
plugins: [
"transform-es3-property-literals", // -sharp2452
"transform-es3-member-expression-literals", // -sharp2566
"transform-runtime" // -sharp2566
]
}
}
< H2 > context < / H2 >
Node v8.11.3
npm v5.6.0
package.json file
"dependencies": {
"axios": "^0.18.0",
"babel-preset-es2015": "^6.24.1",
"element-ui": "^2.4.5",
"js-cookie": "^2.2.0",
"lodash": "^4.17.10",
"md5": "^2.2.1",
"moment": "^2.22.2",
"vee-validate": "^2.1.0-beta.6",
"vue": "^2.5.2",
"vue-cookies": "^1.5.6",
"vue-iconfont": "^1.1.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-cli": "^6.26.0",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-component": "^1.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
"babel-plugin-transform-es3-property-literals": "^6.22.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.11",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"less": "^3.7.0",
"less-loader": "^4.1.0",
"node-notifier": "^5.1.2",
"node-sass": "^4.9.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"sass-loader": "^7.0.3",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"style-loader": "^0.21.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vis": "^4.21.0",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.1.2",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.7.1",
"webpack-merge": "^4.1.0"
},
Thank you Nine for your help