若依 this.$router.push 同地址不同参,页面不刷新问题

简介: 若依 this.$router.push 同地址不同参,页面不刷新问题

背景:若依框架里面默认页面都是缓存的,使用this.$router.push 同地址不同参打开页面时,页面也默认缓存了,导致数据不刷新。


解决办法:


1、打开页面前创建一个标记


sessionStorage.setItem("cgsqmx","Refresh");


2、离开页面时发现有这个标记,然后删若依缓存

beforeRouteLeave (to, from, next) {
  debugger;
    if (to.name === 'Cgsqmx' && sessionStorage.getItem("cgsqmx")==="Refresh") {
      try {
        var cache = this.$vnode.parent.componentInstance.cache;
        var key="";
        for(var prop in cache){
          if(prop.lastIndexOf("cgsqmx")>0){
            key=prop;
          }
        }
        if(key!=""){
          delete cache[key];
        }
      } catch (error) {
      }
      // // console.log('返回管理页面')
      // if (this.$vnode && this.$vnode.data.keepAlive) {
      //   if (this.$vnode.parent && this.$vnode.parent.componentInstance && this.$vnode.parent.componentInstance.cache) {
      //     if (this.$vnode.componentOptions) {
      //       var key = this.$vnode.key == null
      //         ? this.$vnode.componentOptions.Ctor.cid + (this.$vnode.componentOptions.tag ? `::${this.$vnode.componentOptions.tag}` : '')
      //         : this.$vnode.key
      //       var cache = this.$vnode.parent.componentInstance.cache
      //       var keys = this.$vnode.parent.componentInstance.keys
      //       if (cache[key]) {
      //         if (keys.length) {
      //           var index = keys.indexOf(key)
      //           if (index > -1) {
      //             keys.splice(index, 1)
      //           }
      //         }
      //         delete cache["key"]
      //         debugger;
      //       }
      //     }
      //   }
      // }
      this.$destroy()
    }
    next()
  },


3、到达目标页面后,清空标记

sessionStorage.setItem("cgsqmx","");
目录
相关文章
Element的el-table行列错位对不齐问题处理
本文目录 1. 问题表现 2. 问题发现 3. 问题处理 4. 另一种处理方案
6416 0
Element的el-table行列错位对不齐问题处理
|
移动开发 JavaScript HTML5
el-input限制输入整数等分析
本文介绍了在Vue中限制el-input只能输入整数的几种方式,包括设置type为number,使用inputmode属性,自定义指令,计算属性,使用onafterpaste和onkeyup事件以及使用el-input-number的precision属性。每种方式都有其优缺点,可以根据实际需求选择合适的方式。比较建议用自定义指令的方式来实现。
4019 0
el-input限制输入整数等分析
|
JavaScript
Vue中给当前页面传递参数并重新加载,vue使用this.$router.push跳转页面,给跳转过去的页面传参不一致时重新加载
Vue中给当前页面传递参数并重新加载,vue使用this.$router.push跳转页面,给跳转过去的页面传参不一致时重新加载
1163 0
|
JavaScript 网络架构
vue 使用 this.$router.push 传参数,接参数的 query或params 两种方法示例
vue 使用 this.$router.push 传参数,接参数的 query或params 两种方法示例
3599 4
element el-table 设置fixed导致行错乱问题
文章讨论了在使用Element UI的`el-table`组件时,设置固定列(`fixed`)导致行错乱的问题,并提供了解决方案。问题产生的原因是当表格底部有滚动条而固定列底部没有滚动条时,行无法对齐。解决办法是在表格中设置`padding-bottom`的内边距与滚动条高度相等,确保固定列和非固定列的行能够对齐。
5277 0
element table配合from实现双击可编辑表格
如何使用Element UI的el-table和el-form组件实现双击可编辑的表格。
643 0
若依如何创建二级页面菜单,点击目录后,右侧空白的悬浮空白的内容,点击系统管理的菜单管理,上级菜单点击主类木有个小三角,选择我们之前创建的主类目
若依如何创建二级页面菜单,点击目录后,右侧空白的悬浮空白的内容,点击系统管理的菜单管理,上级菜单点击主类木有个小三角,选择我们之前创建的主类目
|
定位技术 API 数据格式
Element UI【详解】el-cascader 级联选择器 - 行政区划选择(可以选择任意一级),限定选择范围,获取并解析选中的节点
Element UI【详解】el-cascader 级联选择器 - 行政区划选择(可以选择任意一级),限定选择范围,获取并解析选中的节点
4458 0
若依修改,切换首页,改成自己想要跳转的login页
若依修改,切换首页,改成自己想要跳转的login页
|
数据安全/隐私保护 网络架构
若依框架 -------- vue3+element-plus(一)
若依框架 -------- vue3+element-plus(一)
1264 1

热门文章

最新文章