UniApp开发--动态计算控价高度

2021-01-28  本文已影响0人  天真的小学童

页面代码:

<view class="header">

</view>

<view class="chat-list">

</view>

<view class="send-box">

</view>

计算公式:

const that = this;

uni.createSelectorQuery().select(".header").boundingClientRect((header) => {

         uni.createSelectorQuery().select(".chat-list").boundingClientRect((chatList) => {

                uni.createSelectorQuery().select(".send-box").boundingClientRect((sendBox) => {

                       console.log(header.height);

                       const windowHeight = uni.getSystemInfoSync()['windowHeight'];

                       const height = (windowHeight /* - header.height */ - chatList.bottom - sendBox.height);

                       that.chatViewHeight = height + 'px';

                }).exec();

       }).exec();

}).exec();

上一篇 下一篇

猜你喜欢

热点阅读