-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[vue] vue要做权限管理该怎么做?如果控制到按钮级别的权限怎么做? #340
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
Comments
可以通过指令去做 |
如果权限角色是动态的,那么要为每个按钮做标识,根据这个标识去查哪些角色拥有该权限,再根据登录人的权限角色进行显示与否。 |
在Vue中进行权限管理的一种常见方式是结合路由和用户角色来控制页面和组件的访问权限。同时,如果需要控制到按钮级别的权限,可以使用条件渲染和指令来实现。 示例定义路由和角色权限:
检查用户权限:
控制按钮级别的权限:
在组件中,通过判断当前用户的角色权限,设置hasButtonPermission变量的值。
通过以上方式,你可以在Vue中实现基于角色的权限管理,控制页面和组件的访问权限,并且可以细粒度地控制到按钮级别的权限。当用户角色发生变化时,你需要相应地更新权限状态并重新渲染组件,以保持权限的正确性。 |
[vue] vue要做权限管理该怎么做?如果控制到按钮级别的权限怎么做?
The text was updated successfully, but these errors were encountered: