VUE中使用axios在IE中自定义Header请求头无效问题

环境

    "axios": "0.18.0",
    "element-ui": "2.4.6",
    "es6-promise": "^4.2.6",
    "js-cookie": "2.2.0",
    "normalize.css": "7.0.0",
    "nprogress": "0.2.0",
    "vue": "^2.5.2",
    "vue-count-to": "1.0.13",
    "vue-router": "^3.0.1",
    "vue-wechat-title": "^2.0.5",
    "vuex": "3.0.1"

1. npm安装babel-polyfill

 npm install babel-polyfill --save-dev
  • 然后在webpack.base.conf.js修改配置
module.exports = {
  context: path.resolve(__dirname, '../'),
  entry: {
    app: ['babel-polyfill', './src/main.js']
  }
  .....
}

2. axios的请求在ie下没有用

npm install es6-promise --save-dev
  • 在main.js配置下
 import promise from 'es6-promise'
 promise.polyfill()

注意:

Chome浏览器对于服务端返回的 Access-Control-Allow-Headers: * 不区分
如果是IE、火狐,360极速兼容模式, 则后台必须修改为 Access-Control-Allow-Headers: 自定义header1,自定义header2

另外:fetch兼容性可参考网址,测试通过
https://www.jianshu.com/p/1fb0213ada79

你可能感兴趣的:(vue,npm)