diff --git a/src/utils/directive.ts b/src/utils/directive.ts index 93d4df7..958121f 100755 --- a/src/utils/directive.ts +++ b/src/utils/directive.ts @@ -2,11 +2,10 @@ import type { App, DirectiveBinding } from 'vue' export default function directive(app: App) { app.directive('auth', (el: HTMLElement, binding: DirectiveBinding) => { - if (binding.modifiers.all ? useAuth().authAll(binding.value) : useAuth().auth(binding.value)) { - el.style.display = '' - } - else { - el.style.display = 'none' - } + watch(() => binding.modifiers.all ? useAuth().authAll(binding.value) : useAuth().auth(binding.value), (val) => { + el.style.display = val ? '' : 'none' + }, { + immediate: true, + }) }) }