解决vue在IE11读取缓存的问题

2022-08-08,,,,

垃圾IE会在发起请求的时候读取接口缓存,就贼蠢,我们要使用时间戳拼接在url来解决。最好不要直接加在参数上,怕后端会进行设置。


function filterUrl (url) {
  return url.indexOf('?') !== -1 ? `${url}&time=${new Date().getTime()}` : `${url}?time=${new Date().getTime()}`
}

例子1:封装get

function get(params, url) {
  return request({
    url: filterUrl(url),
    method: 'get',
    params
  })
}

例子2:封装post

function post(params, url, headersType) {
  return request({
    url: filterUrl(url),
    method: 'post',
    data: params,
    headers: {
      'Content-Type': headersType || 'application/x-www-form-urlencoded'
    }
  })
}

本文地址:https://blog.csdn.net/qq_40282732/article/details/107190273

《解决vue在IE11读取缓存的问题.doc》

下载本文的Word格式文档,以方便收藏与打印。