- 先看图片中的位置区域
![在这里插入图片描述](https://img-blog.csdnimg.cn/5837c7529270459ebea71c35589913d9.png#pic_center)
- 微信小程序小胶囊
![在这里插入图片描述](https://img-blog.csdnimg.cn/a369c47df1794e6da2fa280e60c3a109.png#pic_center)
获取方法示例代码
data: {
statusBarHeight: 0,
titleBarHeight: 0,
headerHeight:0 ,
}
onLoad() {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
},
onReady() {
this.titleBarHeight = (uni.getMenuButtonBoundingClientRect().top - this.statusBarHeight) * 2 +
uni.getMenuButtonBoundingClientRect().height;
this.headerHeight = this.statusBarHeight + this.titleBarHeight;
}
<!-- - Style动态绑定01 -->
<view :style="{'top':`${statusBarHeight}px`}"></view>
<!-- - Style动态绑定02 -->
<view :style="[viewHeight()]">
computed: {
viewHeight() {
let that = this;
console.log('状态栏高度:',that.statusBarHeight);
console.log('导航栏高度:',that.titleBarHeight);
return () => {
let that = this, n = that.statusBarHeight + that.titleBarHeight;
return Object.assign({}, {
top: n + 'px',
})
}
}
}