WXML
<!--components/Header/Header.wxml-->
<view class="header-box" style="height:{{oHeight*2+20}}px;">
<view class="flex" style="height: {{oHeight*2+44}}px;">
<image src="{{src}}" mode="" class="back_img"/>
<view class="title">标题</view>
</view>
</view>
<image src="/images/hm_bg.png" class="bg_img" mode=""/>
WXSS
/* components/Header/Header.wxss */
.header-box{
position: fixed;
width: 100%;
top: 0;
}
.flex{
display: flex;
align-items: center;
}
.back_img{
width: 32rpx;
height: 36rpx;
padding: 10rpx;
}
.title{
position: absolute;
min-width: 400rpx;
text-align: center;
left: 0;
right: 0;
margin: auto;
}
.bg_img{
/* width: 750rpx; */
/* height: 450rpx; */
width: 100%;
}
JS
// app.js
App({
onLaunch() {
let that = this;
wx.getSystemInfo({
success:(res=>{
that.globalData.Height = res.statusBarHeight // 把他给oHeight
})
})
},