合作联系微信: w6668263      合作联系电话:177-9238-7426     

axios的get请求禁止缓存

 

 

用axios拦截器拦截请求,为get请求添加时间戳

 

axios.create({
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    }
})

//axios请求拦截器
axios.interceptors.request.use(config => {
    if (/get/i.test(config.method)) { //判断get请求
        config.params = config.params || {};
        config.params.t = new Date().valueOf(); //添加时间戳
    }
    return config;
}, error => {
    return Promise.reject(error);
})

 

posted on 2024-05-21 09:46  草率的龙果果  阅读(164)  评论(0)    收藏  举报

导航