index.ts 370 B

1234567891011121314151617
  1. /**
  2. * 配置和注册全局指令 directives
  3. */
  4. import { App, Directive } from 'vue'
  5. import { hasPerm, hasRole, autoFocus } from './permission'
  6. const directives = {
  7. hasPerm,
  8. hasRole,
  9. autoFocus
  10. }
  11. export function setupGlobDirectives(app: App) {
  12. Object.keys(directives).forEach(key => {
  13. app.directive(key, (directives as { [key: string]: Directive })[key])
  14. })
  15. }