uniapp 获取元素高度 距离顶部高度等


let _this=this
		   let height=""
		   const query = uni.createSelectorQuery()
		   query.select('#u-dropdown').boundingClientRect()
		   query.selectViewport().scrollOffset()
		   query.exec(function(res){
		    // debugger
		    res[0].top       // #the-id节点的上边界坐标
		    res[1].scrollTop // 显示区域的竖直滚动位置
		    // _this.height=res.windowHeight-res[0].top +'px'
		    // =_this.height
		    height=uni.getSystemInfoSync().screenHeight
		    _this.viewHeight=height-res[0].top-res[0].height
			_this.contentStyle={
				zIndex: -1,
				opacity: 0,
				height:_this.viewHeight+'px'
			}
		    // console.log('打印高度',_this.viewHeight);
		    // console.log('打印demo的元素的信息',res);
		   })
		  }

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM