0
点赞
收藏
分享

微信扫一扫

Vue 关闭当前页面会到上次点击的页面

Greatiga 2022-01-04 阅读 78

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

Vue 关闭当前页面会到上次点击的页面


实现效果

关闭当前页面回到上次点击的页面。

一、相关代码

关闭当前 tags-view ,跳转到上传点击的页面

closeSelectedTag(view) {
      this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
        if (this.isActive(view)) {
          if(visitedViews.length <= 2){
            this.toLastView(visitedViews, view)
          }else{
            if (this.clickTagList.length < 2) {
                this.toLastView(visitedViews, view)
                return
              }
            this.pushClickLastView(view)
          }
        }
      })
    },
    pushClickLastView(view){
      // 跳转
      this.$router.push(this.clickTagList[this.clickTagList.length-2].to.fullPath)
      // 删除
      for(let i = 0; i < this.clickTagList.length; i++){
        if(this.clickTagList[i].to.fullPath === view.fullPath){
          this.clickTagList = this.clickTagList.slice(i, 1);
        }
      }
    },

创作不易,如能对您有所帮助,感谢您的支持,欢迎打赏,充电
在这里插入图片描述在这里插入图片描述

举报

相关推荐

0 条评论