p-honggang.li
5 天以前 80ca024e9ae633df0dc9f4e8f533f33b526afb3d
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
/*
 * @Description:
 * @Version: 2.0
 * @Autor: wuyun
 * @Date: 2022-12-05 14:04:33
 * @LastEditors: wuyun
 * @LastEditTime: 2023-01-29 16:28:02
 */
import { App, Directive } from 'vue'
 
import * as auth from './modules/permission'
import * as tableHeight from './modules/tableHeight'
 
const directivesList: any = {
    tableHeight,
    auth
}
 
const directives = {
    install: function (app: App<Element>) {
        Object.keys(directivesList).forEach((key) => {
            //Object.keys() 返回一个数组,值是所有可遍历属性的key名
            app.directive(key, (directivesList[key] as { [key: string]: Directive })[key]) //key是自定义指令名字;后面应该是自定义指令的值,值类型是string
        })
    }
}
 
export default directives