Prechádzať zdrojové kódy

计算屏幕剩余高度

zhaoxiaohai 2 rokov pred
rodič
commit
e2a52d20cd
1 zmenil súbory, kde vykonal 13 pridanie a 0 odobranie
  1. 13 0
      utils/getRheRemainingHeight.js

+ 13 - 0
utils/getRheRemainingHeight.js

@@ -0,0 +1,13 @@
+ function getHeight(even, that) {
+     return new Promise((resolve, reject) => {
+         let windowHeight = 0;
+         wx.getSystemInfo({
+             success: (res => windowHeight = res.windowHeight)
+         });
+         let query = wx.createSelectorQuery().in(that).select(even).boundingClientRect();
+         query.exec(res => (!res[0]) ? reject('没有查询到元素') : resolve((windowHeight - res[0].bottom) * 2))
+     })
+ }
+ module.exports = {
+     getHeight
+ }