mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
fix(@vant/use): useClickAway failed in SSR (#9899)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Ref, unref } from 'vue';
|
import { Ref, unref } from 'vue';
|
||||||
|
import { inBrowser } from '..';
|
||||||
import { useEventListener } from '../useEventListener';
|
import { useEventListener } from '../useEventListener';
|
||||||
|
|
||||||
export type UseClickAwayOptions = {
|
export type UseClickAwayOptions = {
|
||||||
@@ -10,6 +11,10 @@ export function useClickAway(
|
|||||||
listener: EventListener,
|
listener: EventListener,
|
||||||
options: UseClickAwayOptions = {}
|
options: UseClickAwayOptions = {}
|
||||||
) {
|
) {
|
||||||
|
if (!inBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { eventName = 'click' } = options;
|
const { eventName = 'click' } = options;
|
||||||
|
|
||||||
const onClick = (event: Event) => {
|
const onClick = (event: Event) => {
|
||||||
|
Reference in New Issue
Block a user