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

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

实现代码:

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();
    }
  }
相关推荐
Eason_Lou5 分钟前
vue flow使用注意事项
前端·vue.js
JJJennie77712 分钟前
Gemini 3.7 Flash 上线,Google 想让 AI 多干活
开发语言·javascript·ecmascript
小赵同学WoW1 小时前
1-2 TypeScript 中的 `any` 与 `unknown`
前端
six_1 小时前
C# 上位机(持续更新中)
前端·面试·c#
风雨_1 小时前
Git Worktree sourcetree完整使用指南
前端
半个落月1 小时前
React 组件通信进阶:useContext 与自定义 Hook 实战详解
前端·react.js
MgArcher2 小时前
抖音a_bogus参数逆向实战:JSVMP环境模拟与Hook技术(2025最新)
javascript·爬虫·python
用户921080262862 小时前
ChatComposer 输入区改造:基于技能市场实现 Agent 输入框
前端
用户45989204565162 小时前
一套 KMP 多仓库版本治理工作流:用 Version Catalog + CI 把发版流水线自动化
前端·kotlin
小赵同学WoW2 小时前
1-4 TypeScript 中的 `number`、`bigint` 与 `string`
前端