学无先后,达者为师

网站首页 前端文档 正文

uniapp自定义导航栏 获取高度的方法

作者:helloyuyou 更新时间: 2021-12-08 前端文档

```javascript
	<view :style="{ paddingTop: statusBarHeight + 'px' }">
      <view
        :style="{ height: titleBarHeight + 'px', backgroundColor: 'red' }"
      ></view>
    </view>
data: {
  statusBarHeight: 0,
  titleBarHeight: 0,
}
onLoad() {
    const SystemInfo = wx.getSystemInfoSync();
    this.statusBarHeight = SystemInfo.statusBarHeight;
  },
  
  onReady() {
    this.titleBarHeight =
      (uni.getMenuButtonBoundingClientRect().top - this.statusBarHeight) * 2 +
      uni.getMenuButtonBoundingClientRect().height;
  },

原文链接:https://blog.csdn.net/weixin_43380058/article/details/122133278

栏目分类
最近更新