import { useIntersectionObserver } from '@vueuse/core'
// 数据懒加载
const newTarget = ref(null)
// stop 是一个函数,可以停止观察
const { stop } = useIntersectionObserver(
// 第一个参数是 target, 为要监听的元素
newTarget,
// 第二个参数是回调方法,isIntersecting 表示是否可见
([{ isIntersecting }], observerElement) => {
console.log(isIntersecting ? '可见' : '不可见')
if (isIntersecting) {
getFindNew()
stop()
}
}
)
vue3 数据懒加载
猜你喜欢
转载自blog.csdn.net/m0_59338367/article/details/126527926
今日推荐
周排行