做了一款任何页面返回首页的按钮,代码如下
.back_home{
position: fixed;
width:120rpx;
height:60rpx;
top: 50rpx;
left: 0px;
font-size: 24rpx;
}
<div style="z-index:30"> //用div使按钮在最高层,不会被遮挡
<button bindtap='backToIndex' class="back_home" >
<text>首页</text>
</button>
</div>
效果如下。上下滑动屏幕,按钮位置始终不变。