123456789101112131415161718192021222324 |
- import {
- store
- } from "@/store/index.js"
- const hasRoles = (el, binding) => {
- const {
- value
- } = binding;
- const roles = store.userInfo.roles.map(item => item.roleKey);
- if (value && value instanceof Array && value.length > 0) {
- const hasRole = roles.some(role => {
- return value.includes(role)
- })
- console.log(hasRole);
- if (!hasRole) {
- el.remove()
- }
- } else {
- throw new Error('请填写当前操作权限值')
- }
- }
- export default hasRoles;
|