vue項目在IE下報 [vuex] vuex requires a Promise polyfill in this browser問題

以下圖所示,項目在IE11下打開報錯:node

由於使用了 ES6 中用來傳遞異步消息的的Promise,而IE瀏覽器都不支持。webpack

解決方法:web

第一步: 安裝 babel-polyfill 。 babel-polyfill能夠模擬ES6使用的環境,可使用ES6的全部新方法npm

$ npm install --save babel-polyfill
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ babel-polyfill@6.26.0
updated 1 package and audited 33486 packages in 75.189s
found 18 vulnerabilities (1 low, 10 moderate, 6 high, 1 critical)
  run `npm audit fix` to fix them, or `npm audit` for details

第二步: 在 Webpack中使用

在webpack.config.js文件中,使用瀏覽器

app: ["babel-polyfill", "./src/main.js"]

替換原來的babel

app: './src/main.js'

 以下圖是修改後的位置:app

最後一步:異步

從新啓動項目  npm run dev ui

相關文章
相關標籤/搜索