在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和时间戳