问题:Vue项目开发环境中在IE11正常运行,打包之后发布上线在IE11中报Promise 未定义
1.重要
:确保webpack是2.6.1的版本,如果不是在package.json将webpack修改为”webpack”: “2.6.1”
I had this issue even with adding babel-polyfill, because of a bug with webpack 2.6.0. Upgrading to 2.6.1 solved the issue.
(由于webpack 2.6.0存在错误,即使添加了babel-polyfill,我也遇到了这个问题。 升级到2.6.1解决了这个问题。)
package.json
{
"name": "coreui-vue",
"version": "1.0.0-alpha.6",
"description": "Open Source Admin Template",
"author": "Łukasz Holeczek " ,
"private": true,
"scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js",
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
},
"dependencies": {
"axios": "^0.17.1",
"babel-polyfill": "^6.26.0",
"babel-runtime": "^6.26.0",
"chart.js": "2.5.0",
"echarts": "^4.1.0",
"element-ui": "^2.0.7",
"jquery": "^3.2.1",
"vue": "2.3.3",
"vue-chartjs": "2.6.3",
"vue-router": "2.5.3",
"vue-strap": "github:wffranco/vue-strap"
},
"devDependencies": {
"animate.css": "^3.5.2",
"autoprefixer": "7.1.1",
"babel-core": "6.24.1",
"babel-eslint": "7.2.3",
"babel-loader": "7.0.0",
"babel-plugin-istanbul": "4.1.3",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "1.5.1",
"babel-preset-stage-2": "6.24.1",
"babel-register": "6.24.1",
"chai": "^3.5.0",
"chalk": "^1.1.3",
"chromedriver": "2.29.0",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "5.0.0",
"cross-spawn": "^5.0.1",
"css-loader": "0.28.2",
"eslint": "3.19.0",
"eslint-config-standard": "10.2.1",
"eslint-friendly-formatter": "3.0.0",
"eslint-loader": "1.7.1",
"eslint-plugin-html": "2.0.3",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-node": "4.2.2",
"eslint-plugin-promise": "3.5.0",
"eslint-plugin-standard": "3.0.1",
"eventsource-polyfill": "^0.9.6",
"express": "4.15.3",
"extract-text-webpack-plugin": "2.1.0",
"file-loader": "0.11.1",
"friendly-errors-webpack-plugin": "1.6.1",
"fullcalendar": "^3.8.0",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "0.17.4",
"inject-loader": "3.0.0",
"jquery": "^3.2.1",
"karma": "1.7.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "1.0.4",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "1.3.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "2.0.3",
"lolex": "^1.5.2",
"mocha": "3.4.1",
"nightwatch": "0.9.15",
"node-sass": "^4.7.2",
"opn": "5.0.0",
"optimize-css-assets-webpack-plugin": "1.3.2",
"ora": "1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"rimraf": "^2.6.0",
"sass-loader": "^6.0.6",
"selenium-server": "3.4.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"sinon": "2.3.1",
"sinon-chai": "2.10.0",
"url-loader": "^0.5.7",
"vue-antd": "^0.2.9",
"vue-fullcalendar": "^1.0.9",
"vue-loader": "12.1.0",
"vue-style-loader": "3.0.1",
"vue-template-compiler": "2.3.3",
"webpack": "2.6.1",
"webpack-bundle-analyzer": "2.8.2",
"webpack-dev-middleware": "1.10.2",
"webpack-hot-middleware": "2.18.0",
"webpack-merge": "4.1.0"
},
"engines": {
"node": ">= 4.0.0",
"npm": ">= 3.0.0"
},
"main": ".eslintrc.js",
"directories": {
"test": "test"
},
"license": "ISC"
}
修改package.json中webpack: ‘2.6.1’之后,如果npm run build打包报错,解决方法: 删除node-modules文件夹,重新npm install
2.webpack.base.conf.js
文件修改为
entry: {
app: ['babel-polyfill', './src/main.js']
},
3.main.js
文件在第一行添加
import 'babel-polyfill'
官网使用polyfill的文档:https://babeljs.io/docs/en/babel-polyfill/#usage-in-node-browserify-webpack