Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

路由权限控制 #2

Closed
jisuz opened this issue Oct 24, 2018 · 3 comments
Closed

路由权限控制 #2

jisuz opened this issue Oct 24, 2018 · 3 comments

Comments

@jisuz
Copy link

jisuz commented Oct 24, 2018

你好,我最近在做vue的路由权限控制,参考了你的文章和代码,有写地方看不懂,想请教一下哈。

1.想问一下代码中好像没有体现到路由权限控制这一部分,想问一下这个怎么实现
路由中定义是否需要验证权限:meta:{ auth :true }
就是这个地方,想问一下怎么判断当前角色是否有权限可以访问这个界面

@yimogit
Copy link
Owner

yimogit commented Oct 24, 2018

简而言之就是根据接口返回的modules,判断当前路由的name是否存在modules,不存在则就跳转登录页等操作

1. 登录成功之后返回用户所有的模块编码 code

image

2. 路由守卫中进行判断code

路由钩子里判断一下即可

@jisuz
Copy link
Author

jisuz commented Oct 24, 2018

好的,万分感谢哈,我回去试试看哈,谢谢

@yimogit
Copy link
Owner

yimogit commented Oct 24, 2018

翻车了,刚刚判断写错了,参考思路即可~

@yimogit yimogit closed this as completed Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants