最近需求有個需要點擊返回上級路由關(guān)閉當(dāng)前路由惕味,找了半天記一下
<el-button size="mini" @click="back">返回</el-button>
back() {
// 返回上級路由并關(guān)閉當(dāng)前路由
this.$store.state.tagsView.visitedViews.splice(this.$store.state.tagsView.visitedViews.findIndex(item => item.path === this.$route.path), 1)
this.$router.push(this.$store.state.tagsView.visitedViews[this.$store.state.tagsView.visitedViews.length - 1].path)
}