zoukankan      html  css  js  c++  java
  • 小程序--导航栏切换(tab切换)

    1.展示

    2.代码片段

    WXML
    导航栏
    <view class="swiper-tab">
        <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">未完成</view>
        <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">已完成</view>
    </view>
    
    内容
    <swiper current="{{currentTab}}" class="swiper-box" duration="300" bindchange="bindChange">
        <swiper-item class="swiper-item">
            未完成内容
        </swiper-item>
        <swiper-item class="swiper-item">
            已完成内容
        </swiper-item>
    </swiper>
    JS
     data: {
        currentTab: 0
    },
    //  tab切换逻辑
         swichNav: function( e ) {
     
             var that = this;
     
             if( this.data.currentTab === e.target.dataset.current ) {
                 return false;
             } else {
                 that.setData( {
                     currentTab: e.target.dataset.current
                 })
             }
         },
     
         bindChange: function( e ) {
     
             var that = this;
             that.setData( { currentTab: e.detail.current });
     
         },
    WXSS
    .swiper-tab {
       100%;
      text-align: center;
      height: 100rpx;
      line-height: 100rpx;
      padding: 0 60rpx;
      margin-top: 20rpx;
      margin-bottom: 20rpx;
      background-color: rgb(255, 255, 255);
      display: flex;
      justify-content: space-around;
    }
    
    .swiper-tab-list {
      font-size: 30rpx;
      display: inline-block;
       30%;
      color: #666666;
    }
    
    .on {
      color: #FDA53B;
      border-bottom: 5rpx solid #FDA53B;
    }
    
    .swiper-box {
      display: block;
       100%;
      overflow: hidden;
      box-sizing: border-box;
      font-family: "苹方-简 常规体";
      height: 80vh;
    }
    
    .swiper-box .swiper-item {
      padding: 0 25rpx;
      box-sizing: border-box;
       100%;
      height: 100%;
      overflow-y: scroll;
    }
  • 相关阅读:
    十个提升你Emacs生产力的高招
    emacs 操作集锦
    分页
    JAVA获取CLASSPATH路径
    用Spring的mappingDirectoryLocations来配置Hibernate映射文件
    ajax请求后台,返回json格式数据,模板!
    javascrip中的confirm小技巧
    如何将word图片粘贴到eWebEditor里面
    如何将word图片粘贴到wangEditor里面
    如何将word图片粘贴到xhEditor里面
  • 原文地址:https://www.cnblogs.com/qinlinkun/p/12881811.html
Copyright © 2011-2022 走看看