1. 程式人生 > 實用技巧 >ie瀏覽器會出現“Vuex requires a Promise polyfill in this browser”的錯誤提示

ie瀏覽器會出現“Vuex requires a Promise polyfill in this browser”的錯誤提示

1. 安裝babel-polyfill 執行以下命令,重啟伺服器:
npm install --save babel-polyfill

2.在main.js引入
import 'babel-polyfill'

3.在webpack.base.conf.js中配置:
entry: {
    app: ['babel-polyfill','./src/main.js']
},

擴充:vue cli3---------------解決瀏覽器相容問題
1. 安裝babel-polyfill依賴
 npm i babel-polyfill --save-dev

2.在src同級目錄下新建vue.config.js檔案配置如下

module.exports = {
    configureWebpack: {
        devServer: {
            proxy: {
                //名字可以自定義,這裡我用的是api/
                '/api/': {
                    target: 'https://www.163.com', //設定你呼叫的介面域名和埠號 別忘了加http
                    ws: true, // 是否代理websockets
                    changeOrigin: true, //這裡設定是否跨域
                    pathRewrite: {
                        '^/api/': 'https://www.163.com'
                    }
                }
            }
        }
    },
    chainWebpack: config => {
    // 其他配置
    config.entry('main').add('babel-polyfill') // main是入口js檔案
    // 其他配置
   }
}