前言:
最近碰到一個問題需要對路由信息進行邏輯判斷,但是我們的重定向文件都封裝再一個js中,然后我又要使用 store 中方法,但是this.$store 顯示 undefined 現在解決了 分享一下
解決方法:
直接在當前的js中引入store
import store from '@/store'; //然后直接使用就好了 mutation:store.commit('xxx'); action: store.dispatch('xxx'); state: store.xx