beforeRouteEnter访问Vuex

beforeRouteEnter不能直接this.$store,可采用下面的方式

beforeRouteEnter(to, from, next) {
  const store = from.matched[0].instances.default.$store
  next()
}

[转自]:https://github.com/vuejs/vue-router/issues/1103

posted @ 2021-01-14 19:29  平小宅  阅读(1679)  评论(0编辑  收藏  举报