需要合作伙伴联系我,VX(绿泡泡): w6668263      email:ye583025823@126.com

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  龙行龘龘9527  阅读(47)  评论(0编辑  收藏  举报

导航