使用场景如:当在新增/编辑路由页面提交乐成后,需要关闭当前页,并跳转回列表页。
实当代码:
- this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
- this.$router.replace({ path: "/xxx/xxx" }); // 要打开的页面
复制代码 我这里面开启了若依路由缓存,所以跳回到列表页时,页面并不会刷新。假如需要在回到列表页时主动刷新列表数据,可以在跳转页面跳转前存到当地一个标识,在列表页actived生命周期中获取标识,获取到后将标识置为初始值(不需刷新的标识),并调用列表刷新方法。
实当代码:
- // 在新增/编辑路由页面localStorage.setItem("IndexRefresh", true);this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
- this.$router.replace({ path: "/xxx/xxx" }); // 要打开的页面
复制代码- // 列表页
- ```bash
- activated() {
- if (localStorage.getItem("IndexRefresh") == "true") {
- localStorage.setItem("IndexRefresh", false);
- this.getList();
- }
- }
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |