在我的webapp上使用Vue.js可以在大多数浏览器上工作,除了ie11。我尝试了默认的babel-preset-es2015,也尝试了babel-preset-es2015-ie,但是没有成功:代码仍然没有在ie11上运行,带有'symbol'是未定义的错误。
巴贝尔

{
  "presets": ["es2015"]  << also tried es2015-ie
}

包.json
  "scripts": {
    "dev": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --port 3000 --host 0.0.0.0",
    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
  },
  "dependencies": {
    "bootstrap-loader": "^1.3.2",
    "jquery": "^3.1.1",
    "less": "^2.7.1",
    "less-loader": "^2.2.3",
    "vue": "^2.1.6"
  },
  "devDependencies": {
    "babel-core": "^6.20.0",
    "babel-loader": "^6.2.10",
    "babel-preset-es2015": "^6.18.0",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^1.0.6",
    "css-loader": "^0.23.1",
    "exports-loader": "^0.6.3",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.5",
    "imports-loader": "^0.7.0",
    "json-loader": "^0.5.4",
    "node-sass": "^4.0.0",
    "resolve-url-loader": "^1.6.1",
    "sass-loader": "^4.1.0",
    "style-loader": "^0.13.1",
    "url-loader": "^0.5.7",
    "vue-loader": "^9.8.0",
    "webpack": "^1.14.0",
    "webpack-dev-server": "^1.16.2"
  }

最佳答案

正如@Leonid所指出的,我缺少浏览器polyfill脚本,如this answer所述。现在在ie11(和其他浏览器)上运行良好。
以下是我所做的:

npm install --save-dev babel-polyfill

webpack.config.js文件
module.exports = {
  entry: ['babel-polyfill', './src/main.js'],
  ....
  ....
}

关于javascript - 未定义IE11上未加载Vue.js并显示错误“Symbol”的错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41185734/

10-13 08:56