zoukankan      html  css  js  c++  java
  • 小程序自定义导航栏

    本篇为写给自己看

    index.wxml

        <view class="status-bar" style="height:{{statusBarHeight}}px"></view>
        <view class='nav' style="height:{{titleBarHeight}}px">
          <view class='navLeft'>
            <view class='iconBox' bindtap='tapNavigate' data-item='person'>
              <image class='icon' src='/images/icon-personSmall.png'></image>
            </view>
            <view class='leftLine'></view>
            <view class='iconBox' bindtap='tapNavigate' data-item='message'>
              <image class='icon' src='/images/icon-msg.png'></image>
              <view class='redMsg'></view>
            </view>
          </view>
          <view class='navMid'>商户系统</view>
        </view>
    

      index.wxss

    .nav{
      position: relative;
      left: 0;
       90%;
      margin: 0 auto;
      display: flex;
      align-items: center;
    }
    .navLeft{
       176rpx;
      height: 64rpx;
      background: rgba(0,0,0,0.10);
      border: 1rpx solid rgba(255, 255, 255, 0.205); 
      border-radius: 68rpx;
      position: absolute;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .navMid{ 
      color: white;
      margin: auto;
      font-size: 32rpx;
    }
    
    .iconBox{
      height: 200%;
       50%;
      display: flex;
      align-items: center;
      justify-content: center; 
      position: relative;
    }
    .redMsg{
      position: absolute;
      right: 35%;
      top: 35%;
       10rpx;
      height: 10rpx;
      border-radius: 100%;
      background: red;
    
    }
    .leftLine{
      height: 55%;
      border-left: 1rpx solid rgba(255, 255, 255, 0.219);
    }
    
    .icon{
       32rpx;
      height: 32rpx;
    }

    js

      onLaunch: function () {
        const vm = this
        // let totalTopHeightSet = {
        //   'iPhone': 64,
        //   'iPhone X': 88,
        //   'android': 68
        // }
        wx.getSystemInfo({
          success: function (res) {
            let totalTopHeight = 68
            if (res.model.indexOf('iPhone X') !== -1) {
              totalTopHeight = 88
            } else if (res.model.indexOf('iPhone') !== -1) {
              totalTopHeight = 64
            }
            vm.globalData.statusBarHeight = res.statusBarHeight
            vm.globalData.titleBarHeight = totalTopHeight - res.statusBarHeight
          },
          failure() {
            vm.globalData.statusBarHeight = 0
            vm.globalData.titleBarHeight = 0
          }
        })
      },
  • 相关阅读:
    LeeCode-Spiral Matrix II
    HDU1281(二分图最大匹配,棋盘建图,找关键点)
    HDU1083(二分图最大匹配vector实现)
    HDU2444(判断是否为二分图,求最大匹配)
    HDU1166(线段树单点更新区间查询)
    HDU1045(二分图经典建模)
    POJ1220(大数进制转换)
    POJ3466(01背包变形)
    POJ3180(有向图强连通分量结点数>=2的个数)
    POJ1236 (强连通分量缩点求入度为0和出度为0的分量个数)
  • 原文地址:https://www.cnblogs.com/zwyboom/p/11019439.html
Copyright © 2011-2022 走看看