或然中台小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

16 lines
638 B

/**
* @description 鉴权指令
* 当传入的权限当前用户没有时,会移除该组件
* 用例:<Tag v-auth>text</Tag> 或者:<Tag v-auth="'user:编辑'">text</Tag>
* */
export default {
inserted(el, binding, vnode) {
const btnText = el.innerText
const btnPermissions = uni.getStorageSync('auth')
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText)
// 如果按钮集合里没有该权限,就把该按钮给去除
!isPermission && el.parentNode && el.parentNode.removeChild(el)
}
},
};