Bläddra i källkod

缓存清理

rongxin_dev
庞东旭 5 timmar sedan
förälder
incheckning
e1d17506a8
1 ändrade filer med 15 tillägg och 0 borttagningar
  1. +15
    -0
      src/main.js

+ 15
- 0
src/main.js Visa fil

@@ -194,6 +194,21 @@ Vue.use(VueHtml5Editor,{
// }, false);
// }

//新增版本号(每次更新修改这个值,比如1.0.1 => 1.0.2)
const CURRENT_VERSION ='1.0.0';
const VERSION_KEY = 'app_h5_version';
//对比本地存储的版本号,不一致则清除缓存并刷新
const oldVersion = localStorage.getItem(VERSION_KEY);
console.log(oldVersion)
if(oldVersion !== CURRENT_VERSION) {

localStorage.clear();//清除本地存储
sessionStorage.clear();//清除会话存储
//强制刷新页面(绕过缓存)
location.reload(true);
localStorage.setItem(VERSION_KEY, CURRENT_VERSION);
}

//设置动态登录页
router.beforeEach((to, from, next) => {
if (to.meta.title) {


Laddar…
Avbryt
Spara