From 1945c35b17eaaf52c862cd8276fad0a8e49de833 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 19 Aug 2022 22:04:52 +0800 Subject: [PATCH] fix(PullRefresh): remove passive event warning (#10938) --- packages/vant/src/pull-refresh/PullRefresh.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/vant/src/pull-refresh/PullRefresh.tsx b/packages/vant/src/pull-refresh/PullRefresh.tsx index fa6f6f97a..29f36af63 100644 --- a/packages/vant/src/pull-refresh/PullRefresh.tsx +++ b/packages/vant/src/pull-refresh/PullRefresh.tsx @@ -17,7 +17,7 @@ import { } from '../utils'; // Composables -import { useScrollParent } from '@vant/use'; +import { useEventListener, useScrollParent } from '@vant/use'; import { useTouch } from '../composables/use-touch'; // Components @@ -61,6 +61,7 @@ export default defineComponent({ let reachTop: boolean; const root = ref(); + const track = ref(); const scrollParent = useScrollParent(root); const state = reactive({ @@ -220,6 +221,15 @@ export default defineComponent({ } ); + // add passive option to avoid Chrome warning + useEventListener('touchstart', onTouchStart as EventListener, { + target: track, + passive: true, + }); + useEventListener('touchmove', onTouchMove as EventListener, { + target: track, + }); + return () => { const trackStyle = { transitionDuration: `${state.duration}ms`, @@ -231,10 +241,9 @@ export default defineComponent({ return (