github: https://blog.csdn.net/Chen_ITO/article/details/83651917

微信小程序,左上角返回首页小房子

 

 

需求:

微信小程序分享出去的页面,需要左上角加上小房子,点击回到主页;

这里就需要涉及到自定义头部

效果图:

微信小程序,左上角返回首页小房子

代码:

PS: 代码直接复制到wxml和wxss里面即可

1、在test.json中加入

 

{
"navigationStyle": "custom"
}

 


这个就是全屏的意思

2、在test.xml中加入

 

 
  <view class="inaver _30f2b4d" style="background:{{background}};color:{{getColor}}">
    <view class="left _30f2b4d" catchtap="goBack">
      <image class="icon _30f2b4d" src="/images/ic_home_normal.png"/>
    </view>
    <view class="center _30f2b4d">
      <!-- 自定义区域 -->
      
      
    </view>
    <view class="right _30f2b4d">
      <!-- 保护右上角胶囊不被污染 -->
    </view>
  </view>
  <view  class="protect-inaver _30f2b4d">
    <!-- 占据顶部位置, 伪padding板块 -->
  </view>

ic_home.png自己加自己的

3、在test.wxss中加入

.inaver._30f2b4d {
  box-sizing: border-box;
  padding-top: 44rpx;
  width: 100vw;
  height: 160rpx;
  display: flex;
  position: fixed;
  z-index: 5000;
  top: 0;
  left: 0;
}
 
.inaver .left._30f2b4d {
  width: 100rpx;
  height: 100rpx;
  margin: 8rpx;
}
 
.inaver .left image.icon._30f2b4d {
  width: 60rpx;
  height: 60rpx;
  padding: 10rpx;
  margin: 10rpx;
}
 
.inaver .center._30f2b4d {
  height: 100rpx;
  line-height: 100rpx;
  flex: 1;
  margin: 8rpx;
}
 
.inaver .right._30f2b4d {
  width: 240rpx;
  height: 100rpx;
  margin: 8rpx;
}
 
.protect-inaver._30f2b4d {
  box-sizing: border-box;
  width: 100vw;
  height: 160rpx;
}

相关文章:

  • 2022-12-23
  • 2022-01-05
  • 2022-01-04
  • 2022-01-07
  • 2021-07-30
  • 2021-07-06
  • 2021-09-28
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-12-15
  • 2021-12-29
  • 2021-12-08
相关资源
相似解决方案