Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在每次路由器更改之前检查数据是否存储,如果数据不在 vuex 中,我想使用 vuex 的操作从服务器获取数据。那么我如何在 beforeEach 中进行用户操作。
我用的是vue2.0
可以使用 router.app.$store.dispatch('actionName')
您所要做的就是import store from '/vuex和操作取决于您构建操作的方式,您可以被推送以将存储实例传递给操作。除此之外 - 它是直截了当的。
import store from '/vuex