uniapp 自动分页器

v3版本

<div class="loading" ref="loading">
	{
   
   {isLoading}}
</div>


onMounted(() => {
const observer = new IntersectionObserver((entries) => {
	if (entries[0].isIntersecting) {
		if(data.total>0&&data.list.length==data.total) return
		isLoading.value = "正在加载更多数据~~"
		integralListApiFn(data.pageNumber + 1) 
	        }
	})
	observer.observe(document.querySelector('.loading')) 
})
       
       
.loading {
font-size: 24rpx;
color: #979797;
margin: 40rpx auto;
width: fit-content;
}                

v2版本

 <view ref="element" class="element"></view>
 
 
mounted() {
    this.observer = uni.createIntersectionObserver(this)
    this.observer.relativeToViewport().observe('.element', (res) => {
      if (res.intersectionRatio > 0) {
        
      } 
    })
   
}


.element {
  height: 30rpx;
}

或者scroll-view列表循环,然后通过滚动条位置判断

猜你喜欢

转载自blog.csdn.net/m0_59203969/article/details/134293646