效果图
![](https://i-blog.csdnimg.cn/blog_migrate/65943a1c2895dea33e8a96339d730c8f.png)
wxml
<view class="nav-bar" style="height:{{capsuleButton.bottom+5}}px">
<view class="nav-bar-box"></view>
<view style="width:{{capsuleButton.width+(phoneInfo.screenWidth - capsuleButton.right)+5}}px;background:#ccc;"></view>
</view>
wxss
.nav-bar{
width: 100%;
height: 150rpx;
background: red;
display: flex;
}
.nav-bar-box{
flex: 1;
}
js
data: {
capsuleButton:{},
phoneInfo:{},
},
onLoad: function (options) {
this.setData({
phoneInfo: wx.getSystemInfoSync(),
capsuleButton:wx.getMenuButtonBoundingClientRect()
})
},
}