uni-app 下拉至指定高度固定view

uni.createSelectorQuery().select(‘#salyt’).boundingClientRect(function(rects){
					console.log(rects)
					var query = uni.createSelectorQuery()
					query.select('#main').boundingClientRect()
					query.selectViewport().scrollOffset()
					query.exec(function(res){
						uni.pageScrollTo({
							scrollTop: rects.top + res[1].scrollTop,
							duration: 300
						})
					})
					
				}).exec();

  

uni.createSelectorQuery().select(‘#salyt’).boundingClientRect(function(rects){}这行的结果是指定Id元素距离屏幕顶端的高度  

query.select('#main').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec(function(res){
  uni.pageScrollTo({
	scrollTop: rects.top + res[1].scrollTop,
	duration: 300
  })
 })
这行的结果res是指定最外围的view 滚动的距离


posted @ 2018-10-15 17:51  罪途  阅读(7053)  评论(0编辑  收藏  举报