关于IE11浏览器同意请求只执行一次的解决方法

在IE11,

import axios from "axios";

let ser = axios.create({
  headers: {
    'Cache-Control': 'no-cache'
  }
});

ser.interceptors.request.use(config => {
  if (config.method === 'post' || config.method === 'POST') {
    config.data = {
      ...config.data,
      _t: new Date().getTime()
    }
  }else if (config.method === 'get' || config.method === 'GET') {
    config.params = {
      _t: new Date().getTime(),
      ...config.params
    }
  }

  return config
},function (error) {
  return Promise.reject(error)
})

Vue.prototype.$axios = ser;

然后在你的所有页面中只需要使用this.$axios即可,不一定腰带时间戳了,因为此处已经配置了nocache和时间戳

posted @ 2021-01-27 19:03  昜木辰deブログ  阅读(163)  评论(0编辑  收藏  举报