SecurityDirective.ts
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// @ts-ignore
import store from '@/store';
import {Privilege} from './Privilege';
const SecurityDirective = {
// 在绑定元素的父组件挂载之前调用
beforeMount(el: any, binding: any, vnode: any, prevVnode: any) {
},
// 在绑定元素的 attribute 或事件监听器被应用之前调用
created() {
//
},
// 在绑定元素的父组件挂载之后调用
mounted(el: any, binding: any) {
const privileges = store.getters['security/getPrivileges'];
const privilege = Privilege.findPrivilegeByCode(binding.value, privileges);
if (!privilege) {
el.remove();
}
},
// 在包含组件的 VNode 更新之前调用
beforeUpdate() {
//
},
// 在包含组件的 VNode 及其子组件的 VNode 更新之后调用
updated() {
//
},
// 在绑定元素的父组件卸载之前调用
beforeUnmount() {
//
},
// 在绑定元素的父组件卸载之后调用
unmounted() {
//
}
}
export default SecurityDirective;