zoukankan      html  css  js  c++  java
  • 微信小程序(自定义底部篇)

    要点:###

    1. 需要把 custom-tab-bar 文件放在pages同级

    1. 在app.json中配置底部导航栏代码(没配置不能点击)

    1. 开始放代码:

    在app.json中配置

    "usingComponents": {
        "custom-tab-bar": "./custom-tab-bar/index"
      },
    

    wxml:

    <view class="tab-bar">
      <view wx:for="{{list}}" wx:key="index" class="tab-bar-item {{item.bulge?'bulge':''}}" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
        <view  wx:if="item.bulge" class="tab-bar-bulge tab-bar-view"></view>
        <image class="image" src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image>
        <view  wx:if="{{item.text}}" style="color: {{selected === index ? selectedColor : color}}" class="tab-bar-view">{{item.text}}</view>
      </view>
    </view>
    

    wxss:

    .tab-bar {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      height: 48px;
      background: #FFF;
      display: flex;
      line-height: 1.2;
      padding-bottom: env(safe-area-inset-bottom);
      /* border-top: 1px solid #e6e6e6; */
    }
    
    .tab-bar-item {
      flex: 1;
      text-align: center;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
    }
    .tab-bar-item .image {
       27px;
      height: 27px;
    }
    .bulge {
      background-color: #FFF;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .bulge .image{
       90rpx;
      height: 90rpx;
    }
    
    .tab-bar-item .tab-bar-view {
      font-size: 10px;
      margin-top: 5rpx;
    }
    

    js:

    onShow: function () {
        if (typeof this.getTabBar === 'function' && this.getTabBar()) {
          this.getTabBar().setData({
            //selected 代表顺序
            selected: 0
          })
        }
      },
    

  • 相关阅读:
    卸载linux自带openjdk并安装sun jdk
    配置互信
    【学习笔记】计算理论
    python 矩阵乘法
    一个python二维列表格式化美观输出的题目
    【学习笔记】SICP读书笔记&&UCB CS61A学习笔记(学习中。。。)
    js模块化编程(未完待续)
    js——封装音频播放 暂停
    js——构造函数手撕大转盘
    kubernetes的iptables与ipvs详解
  • 原文地址:https://www.cnblogs.com/yx-liu/p/14241417.html
Copyright © 2011-2022 走看看