//获取胶囊高度
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.titleTop = (menuButtonInfo.top) //标题文字的position:top
this.titleHeight = (menuButtonInfo.height) //标题文字的高度
//背景的高度=top+height+需要的下方高度
this.bgHeight = (menuButtonInfo.top) + (menuButtonInfo.height) + 80
CSS样式:
:style="[{paddingTop:titleTop+'px'},{height:bgHeight+'px'}]"
适配刘海:
.status_bar { height: var(--status-bar-height); width: 100%; }