{
// 登录
path:'/login',
component: resolve => require(['@/app/Page/login/login.vue'], resolve),
meta: {title: '登录',wxAuth: true},
beforeEnter (to, from, next) {
if (auth.loggedIn()) {
next('/home')
} else {
next()
}
}
},
如上面是js文件中的一段代码,我想在if(auth.loggedIn()){}里面调用在vue里面的methods中创建的这个方法
getLocation() {
return this.$store.dispatch("get", {
uri: consts.PREFIX + "/city/open/location"
});
},
该怎么实现
兄dei换个思路,试试在组件内使用
beforeRouteEnter
如何? 看你代码的用意是也是想事先发起一个get
请求..这种东西文档里也有说明的