项目场景:
普通按钮或者组件按钮,都可。
问题描述
判断用户是否拥有新增、编辑、删除、查询等功能的按钮权限。
具体操作:
- 先获取权限集合,存储到vxe中------一般都是在接口里面获取
- 创建js页面,封装函数
- 创建子组件页面,封装button组件
- 再到所需的父组件页面引用子组件页面
实现:
- 举个例子:在首页中拿个函数,把权限存储到vxe中
initData(){
let arr = [
"dept:shareDept:add",
"dept:shareDept:edit"
]
store.commit("setPerms",arr)
}
2. 在src目录下创建个目录[permission],再创个index.js文件
/*
* index.js
*/
import store from '@/store'
export function hasPermission(perms){
let hasPermissio