[英]Hide/Display an element depending on a property assigned to a user role
I'm working on separating 2 main user roles, editor and guest.我正在努力分离 2 个主要用户角色,编辑和来宾。 Editor as such is the one that has every privilege at hand for the CRUD, but guest can only view certain elements such as a List but cannot make use of some specific operations.编辑器本身就拥有 CRUD 的所有特权,但访客只能查看某些元素,例如列表,但不能使用某些特定操作。 Is there any way in vuejs to hide those elements when a user is created with, let's say, a "privilegeType" guest property?当使用“privilegeType”来宾属性创建用户时,vuejs 有什么方法可以隐藏这些元素?
You could just get the user data.你可以只获取用户数据。 Have a state, stating the user roles.有一个 state,说明用户角色。 Using v-if
to hide and show element based on the user roles.使用v-if
根据用户角色隐藏和显示元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.