vue-element-admin关闭当前标签页
微wx笑
2021-03-22【前端开发】
4
0关键字:
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笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/front/2021-03-22/629.html



