import{o as a,a as t,y as n}from"./vue-libs.b44bc779.js";const e={class:"van-doc-markdown-body"},l=n(`
Get the closest parent element that is scrollable.
<div ref="root" />
import { ref, watch } from 'vue';
import { useScrollParent, useEventListener } from '@vant/use';
export default {
setup() {
const root = ref();
const scrollParent = useScrollParent(root);
useEventListener(
'scroll',
() => {
console.log('scroll');
},
{ target: scrollParent }
);
return { root };
},
};
function useScrollParent(
element: Ref<Element | undefined>
): Ref<Element | Window | undefined>;
Name | Description | Type | Default Value |
---|---|---|---|
element | The current element | Ref<Element> | - |
Name | Description | Type |
---|---|---|
scrollParent | The closest parent element that is scrollable | Ref<Element> |