vue-element-admin关闭当前标签页
微wx笑2021-03-22 17:16:56【前端开发】人已围观关键字:
vue element admin 关闭 当前 标签页
如果是普通的标签页,以下代码就可以了:// 调用全局挂载的方法this.$store.dispatch('tagsView/delView', this.$route) // 删除当前标签页// 返回上一步路由this.$rou
如果是普通的标签页,以下代码就可以了:
// 调用全局挂载的方法 this.$store.dispatch('tagsView/delView', this.$route) // 删除当前标签页 // 返回上一步路由 this.$router.go(-1) // 返回上一个标签页,有点类似 history.go(-1)
但是比如我从一个列表页面,打开一个新的编辑的标签页,然后做了以下设置:
setTagsViewTitle() { const title = this.lang === 'zh' ? '编辑文章' : 'Edit Article' const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.postForm.id}` }) this.$store.dispatch('tagsView/updateVisitedView', route) },
上面的代码就不管用了,那应该怎么办呢?
因为我们对 route 做了修改,所以在删除的时候要这样:
// 调用全局挂载的方法 const title = this.lang === 'zh' ? '编辑文章' : 'Edit Article' const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.postForm.id}` }) this.$store.dispatch('tagsView/delView', route) // this.$route // 返回上一步路由 if (this.isEdit) { this.$router.go(-1) }else{ this.$router.push('/cmscontent/list'); }
你明白了吗?
本文由 微wx笑 创作,采用 CC BY-NC 4.0 许可协议。 非商业性使用可自由转载、引用、甚至修改,但需署名作者且注明出处。