zoukankan      html  css  js  c++  java
  • 微信小程序tab切换

    1.html布局

    <view class='title'>
        <view class="{{0 == currentIndex ? 'title-sel-selected' : 'title-sel'}}" bindtap='titleClick' data-idx='0'>
            <text>直播</text>
            <hr class="line-style" />
        </view>
        <view class="{{1 == currentIndex ? 'title-sel-selected' : 'title-sel'}}" bindtap='titleClick' data-idx='1'>
            <text>回放</text>
            <hr class="line-style" />
        </view>
    </view>
    

      

    2.相关css
    page{
        background:#fff;
    }
    .title {
         100%;
        height: 88rpx;
        background: white;
        display: flex;
        align-items: center;
        justify-content: space-around;
        border-bottom: 2rpx solid rgba(235,235,235,1);
    }
    .title text{
        line-height: 82rpx;
    } 
    .title-sel {
      color: #24272c;
      font-size: 32rpx;
      display: flex;
      flex-direction: column;
      align-items: center;
     height: 88rpx;
    }
     
    .title-sel  .line-style{
      /* background: #fff; */
      height: 6rpx;
       40rpx;
      position: relative;
      margin-top: 10rpx;
    }
     
    .title-sel-selected{
      color: #006bff;
      font-size: 32rpx;
      display: flex;
      flex-direction: column;
      align-items: center;
     height: 88rpx;
    }
    .title-sel-selected .line-style{
      background: #006bff;
      height: 6rpx;
       56rpx;
      position: relative;
      border-radius:4rpx;
      /* margin-top: 1rpx; */
    }
    

      


    3.相关js
    data: {
            currentIndex: 0,
        },
     titleClick: function (e) {
            let currentPageIndex =
                this.setData({
                    //拿到当前索引并动态改变
                    currentIndex: e.currentTarget.dataset.idx,
                    zblist: [],
                    inputValue: '',//清空搜索框
                    page: 1
                })
            console.log(e.currentTarget.dataset.idx)
        },
    

      


     
     
  • 相关阅读:
    机器学习-数据归一化及哪些算法需要归一化
    目标检测中的mAP
    在Ubuntu内制作自己的VOC数据集
    目标检测算法之YOLOv3
    目标检测算法之YOLOv1与v2
    详谈Windows消息循环机制
    位和字节以及各类编码简述
    C++ 基础知识(一)
    Python 爬取高清桌面壁纸
    WPF 动画执行后属性无法修改
  • 原文地址:https://www.cnblogs.com/xiaohuohuai/p/13555197.html
Copyright © 2011-2022 走看看