PanJiaChen / vue-element-admin

:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin
MIT License
88.16k stars 30.49k forks source link

怎么在页面里面,关闭一个或者当前TagsView #822

Closed Mustang-666 closed 6 years ago

Mustang-666 commented 6 years ago

你好问下: A:列表页, B:详情页 A进入B,当前TagsView,2个 B处理业务结束后,关闭B跳转到A,或者关闭B跳转到另一个页面C

怎么实现?

AndsteLyc commented 6 years ago

以下是关闭当前tagView

修改:/src/store/modules/tagsView.js 在第72行下面加上:

delCurrentViews({ commit, state }, params) {
  commit('DEL_VISITED_VIEWS', params.view)
  const latestView = [...state.visitedViews].slice(-1)[0]
  if (latestView) {
    params.$router.push(latestView)
  } else {
    params.$router.push('/')
  }
}

然后在你的页面里使用:

this.$store.dispatch('delCurrentViews', {
  view: this.$route,
  $router: this.$router
})

希望可以帮到你。

Mustang-666 commented 6 years ago

好的,谢谢。

PanJiaChen commented 6 years ago

参照 https://github.com/PanJiaChen/vue-element-admin/issues/641

marscj commented 5 years ago

var view = this.$route this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => { const latestView = visitedViews.slice(-1)[0] if (latestView) { this.$router.push(latestView) } else { if (view.name === 'Dashboard') { this.$router.replace({ path: '/redirect' + view.fullPath }) } else { this.$router.push('/') } } })

001117 commented 1 year ago

store怎么写