一般情况下,都是在router.beforeEach((to, from, next) => {})中使用。

1、调用接口,能在这调用接口的一般都是使用get来获取数据
直接 Axios.get(接口).then(res=>{}).catch(err=>{}),就可以调用接口了

2、访问vuex中的数据
想要获取或操作vuex中的数据,
获取数据: id: store.state.id
操作数据: store.state.id=res.data.data.id

Logo

前往低代码交流专区

更多推荐