【若依】关闭当前标签页并跳转路由到其他页面

使用场景如:当在新增/编辑路由页面提交成功后,需要关闭当前页,并跳转回列表页。

实现代码:

bash 复制代码
this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
this.$router.replace({ path: "/xxx/xxx" }); // 要打开的页面

我这里面开启了若依路由缓存,所以跳回到列表页时,页面并不会刷新。如果需要在回到列表页时主动刷新列表数据,可以在跳转页面跳转前存到本地一个标识,在列表页actived生命周期中获取标识,获取到后将标识置为初始值(不需刷新的标识),并调用列表刷新方法。

实现代码:

bash 复制代码
// 在新增/编辑路由页面
localStorage.setItem("IndexRefresh", true);
this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
this.$router.replace({ path: "/xxx/xxx" }); // 要打开的页面
bash 复制代码
// 列表页
```bash
activated() {
    if (localStorage.getItem("IndexRefresh") == "true") {
      localStorage.setItem("IndexRefresh", false);
      this.getList();
    }
  }
相关推荐
OEC小胖胖4 小时前
去中心化身份:2025年Web3身份验证系统开发实践
前端·web3·去中心化·区块链
Cacciatore->4 小时前
Electron 快速上手
javascript·arcgis·electron
vvilkim5 小时前
Electron 进程间通信(IPC)深度优化指南
前端·javascript·electron
某公司摸鱼前端6 小时前
ES13(ES2022)新特性整理
javascript·ecmascript·es13
ai小鬼头7 小时前
百度秒搭发布:无代码编程如何让普通人轻松打造AI应用?
前端·后端·github
漂流瓶jz7 小时前
清除浮动/避开margin折叠:前端CSS中BFC的特点与限制
前端·css·面试
前端 贾公子7 小时前
在移动端使用 Tailwind CSS (uniapp)
前端·uni-app
散步去海边7 小时前
Cursor 进阶使用教程
前端·ai编程·cursor
清幽竹客7 小时前
vue-30(理解 Nuxt.js 目录结构)
前端·javascript·vue.js
知性的小mahua7 小时前
echarts+vue实现中国地图板块渲染+省市区跳转渲染
vue.js