(@_@;)我是程序猿,我编程,我快乐,知识改变命运,技术成就梦想   oh yeah!合作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  一个草率的龙果果  阅读(34)  评论(0编辑  收藏  举报

导航