diff --git a/packages/vant-use/src/useClickAway/index.ts b/packages/vant-use/src/useClickAway/index.ts index 8a936eef7..6011d6454 100644 --- a/packages/vant-use/src/useClickAway/index.ts +++ b/packages/vant-use/src/useClickAway/index.ts @@ -1,4 +1,5 @@ import { Ref, unref } from 'vue'; +import { inBrowser } from '..'; import { useEventListener } from '../useEventListener'; export type UseClickAwayOptions = { @@ -10,6 +11,10 @@ export function useClickAway( listener: EventListener, options: UseClickAwayOptions = {} ) { + if (!inBrowser) { + return; + } + const { eventName = 'click' } = options; const onClick = (event: Event) => {