let _this=this let height="" const query = uni.createSelectorQuery() query.select( ...
var that this const query uni.createSelectorQuery .in that query.select 元素 .boundingClientRect data gt console.log data .exec ...
2020-11-03 11:36 0 3218 推薦指數:
let _this=this let height="" const query = uni.createSelectorQuery() query.select( ...
onPageScroll(e){ console.log(e); } ...
<view id='box'></view> view.js ...
function getDisTop(element) { //獲取元素距離頁面頂部的距離 var realTop = element.offsetTop; var parent ...
data回調參數包括了組件的一些信息,包括距離頭部的距離 使用這個方法獲取距離時 有兩個條件:1、在onReady或者mounted中使用;2、保證前面的圖片高度設置好了,因為uni-image有個默認高度為 height: 240px ,容易造成偏差; 3、正常 ...
<cpn ref="aa"></cpn> ...
樓梯效果: ...
思考:為什么要累加? 因為offsetTop返回的是當前對象距離上一層父級節點的距離; 如果元素有多個父級,則必須要累加 請參考:JS中offsetTop、clientTop、scrollTop、offsetTop各位置屬性詳解(含示例圖) 解決辦法: js: 親測有效 ...