// 定义指令,按钮权限控制
import Vue from 'vue'
const has = Vue.directive('has', {
inserted: function (el, binding) {
if (!Vue.prototype.$has(binding.value)) {
el.parentNode.removeChild(el)
}
}
})
// 判断是否有权限方法
Vue.prototype.$has = function (value) {
let isExist = false
// 获取所有权限按钮
let authBtn = JSON.parse(sessionStorage.getItem('authBtn'))
// 判断当前按钮是否在所有权限按钮列表中
if (authBtn && value && authBtn.indexOf(value) !== -1) {
isExist = true
}
return isExist
}
export {
has
}