
使用 Vue Element 关闭当前标签并跳转至上一页面的操作
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
本教程详解如何在Vue.js项目中利用Element UI组件库实现关闭当前导航标签同时返回上一页的功能。
方法一:使用 `this.$store.dispatch(delVisitedViews, this.$route);` 删除已访问的视图,然后通过 `this.$router.go(-1);` 返回上一个路由。
方法二:直接操作状态管理中的 `tagsView.visitedViews` 数组,找到当前路径对应的项并删除。具体做法是使用数组的 `splice()` 方法和 `findIndex()` 方法来定位要移除的元素,并将其从数组中移除。然后通过 `this.$router.push(this.$store.state.tagsView.visitedViews[this.$store.state.tagsView.visitedViews.findIndex(item => item.path === this.$route.path) - 1])` 跳转到上一个视图(如果存在的话)。
全部评论 (0)
还没有任何评论哟~


