uniapp自动滚动到底部

这个没什么可以讲的就是获取dom然后跳到到dom位置,直接上代码,复制直接能用。

<view class="" style="width: 100%;height: 60px;" id="_box"></view>//页面最底部的元素

	
const observer = uni.createIntersectionObserver()

observer.relativeToViewport().observe('#_box', (res) => {
console.log(1,res)
 if (res.intersectionRatio > 0) {
	console.log('Target element is visible')
	  // scroll to the bottom of the page
	    uni.pageScrollTo({
	   scrollTop: 10000,
	    duration: 500
	   })
		  }
		})

猜你喜欢

转载自blog.csdn.net/xybhua/article/details/130178763