<!-- 吸顶 -->
<u-sticky :offset-top="topheight" z-index="999" h5-nav-height="48">
<view>
<u-tabs
:list="tabList"
:current="currentTabIndex"
@change="changeTabIndex"
bar-height="6"
bar-width="60"
active-color="#2979ff"
font-size="14px"
></u-tabs>
</view>
</u-sticky>
data() {
return {
topheight: 0,
tabList: [
{
name: "tab1",
},
{
name: "tab2",
},
],
currentTabIndex: 0,
};
},
created() {
this.getTopHeight();
},
methods: {
getTopHeight() {
let that = this;
uni.getSystemInfo({
success: function (e) {
let topPx = e.statusBarHeight + 48
that.topheight = topPx / (uni.upx2px(topPx) / topPx)
},
});
},
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/60945c9eaa56bcc8560f70ceb160781c.png)