add v-permission

木子李·De 3 years ago
parent 7004ad4ffc
commit ade445ca48

@ -0,0 +1,13 @@
import permission from './permission'
const install = function (Vue) {
Vue.directive('permission', permission)
}
if (window.Vue) {
window['permission'] = permission
Vue.use(install) // eslint-disable-line
}
permission.install = install
export default permission

@ -0,0 +1,14 @@
import store from '@/store'
export default {
inserted(el, binding, vnode) {
const { value } = binding // v-permission 绑定的权限值
const auths = store.getters && store.getters.authorities // 拥有的权限列表
if (value) {
//auths.indexOf(value) === -1 && el.parentNode && el.parentNode.removeChild(el)
} else {
// 未绑定权限值或者绑定的权限值为 假
return
}
},
}
Loading…
Cancel
Save