store-management-app/utils/permission.js
2024-10-17 17:46:46 +08:00

23 lines
581 B
JavaScript

export default (app) => {
// 按钮权限/show-btn
app.directive("permission", {
beforeMount(el, binding) {
const btnList = uni.getStorageSync("ruleBtn")
? uni.getStorageSync("ruleBtn")
: [];
if (
(binding.value &&
btnList.length > 0 &&
!btnList.includes(binding.value)) ||
btnList.length == 0
) {
// 解决进入页面按钮会闪一下再消失问题
el.style.display = "none";
setTimeout(() => {
el.parentNode.removeChild(el);
}, 0);
}
},
});
};