鍍金池/ 問答/HTML/ 微信小程序怎么測算一個view距離頂部標(biāo)題欄的高度

微信小程序怎么測算一個view距離頂部標(biāo)題欄的高度

微信小程序怎么測算一個view距離頂部標(biāo)題欄的高度

回答
編輯回答
編輯回答
心上人

答案在這里:點(diǎn)這里

2017年3月17日 04:40
編輯回答
尐懶貓

要是使用節(jié)點(diǎn)查詢比較頻繁的話可以封裝一下,value就是你要選擇的元素選擇器,_this是從pages頁面?zhèn)鬟^的this

export let domInter = (value, _this) => {
  return new Promise((resolve, reject) => {
    var query = wx.createSelectorQuery().in(_this)
    query.select(value).boundingClientRect(function (res) {
      resolve(res)
    }).exec()
  })
}
使用
doInter('.dom',this).then((res) => {
    console.log(res)
})
2018年3月24日 08:17