浏览代码

缓存清理

rongxin_dev
庞东旭 8 小时前
父节点
当前提交
e1d17506a8
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. +15
    -0
      src/main.js

+ 15
- 0
src/main.js 查看文件

@@ -194,6 +194,21 @@ Vue.use(VueHtml5Editor,{
// }, false); // }, 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) => { router.beforeEach((to, from, next) => {
if (to.meta.title) { if (to.meta.title) {


正在加载...
取消
保存