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