• 小程序实现自定义导航栏


    1. 组件nav的WXML
      <view class='nav-wrapper'>
        <text wx:if="{{showBack}}" class='iconfont icon-fanhui nav-back' catchtap='onRouteBack'></text>
        <view class='nav-title'>{{title}}</view>
      </view>
    2. 组件nav的JS
    Component({
      properties: {
        title:{
          type:String,
          value:''
        },
        showBack:{
          type:Boolean,
          value:true
        }
      },
      methods: {
        onRouteBack(){
          wx.navigateBack();
          this.triggerEvent('back')
        }
      }
    })

    3. 组件nav的WXSS
    .nav-wrapper{
       100%;
      height: 132rpx;
      display: flex;
      justify-content: center;
      align-items: flex-end;
      padding-bottom: 20rpx;
      box-sizing: border-box;
      position: relative;
    }
    .nav-wrapper .nav-title{
      font-size: 35rpx;
    }
    .nav-wrapper .nav-back{
      font-size: 34rpx;
      position: absolute;
      left: 20rpx;
      bottom: 25rpx;
    }

    4. 在页面中的使用
      在JSON文件中
      {
        "usingComponents": {
          "nav": "../../../components/nav/index",
          "more-data": "../../../components/moreData/index"
        },
        "navigationStyle": "custom"
      }
     在WXML文件中
      <nav></nav>

  • 相关阅读:
    数据结构与算法
    android vitamio的坑
    Fragment的坑
    scrollview里面嵌套listview的坑
    关于微信小程序的tabbar
    Intent初级学习
    HDU 4562 守护雅典娜
    SGU 542 Gena vs Petya
    [二] EditText and Button
    A Data Structure for Dynamic Trees
  • 原文地址:https://www.cnblogs.com/qianxiaoniantianxin/p/14500797.html
Copyright © 2020-2023  润新知