《样式设计002:tab切换与底部swiper滑动块》


 

描述:在开发小程序过程中,发现一些不错的案例,平时使用也比较多,稍微总结了下经验,以下内容可以直接复制使用,希望对大家有所帮助,废话不多说直接上干货!

一、tab切换与底部swiper滑动块

(二)样式截图

(二)wxml代码


<!-- (3.2)tab页-内容 -->
<view class="test_content margin-top-lg solid bg-grey" style="height: 300rpx;">
  <!-- swiper和swiper-itm一起用 -->
  <swiper style="height: 98%;" indicator-dots="{{false}}" indicator-active-color="#fff" indicator-color="#9b9b9b" autoplay="{{false}}" circular="{{false}}" vertical="{{false}}" duration="{{300}}" current="{{tabCur}}" bindchange="onSwiperChange">
    <!-- 页面1 -->
    <swiper-item style="background-color: #A5C281; ">
      <scroll-view style="height: 100%;" scroll-y='true'>
        <grid-view type="masonry" cross-axis-count="3" cross-axis-gap="5" main-axis-gap="5">
          <view class='bg-gradual-pink' wx:for="123456789123456789" wx:key="index" style="height: 40px;">
            页面1:索引 {{index}}
          </view>
        </grid-view>
      </scroll-view>
    </swiper-item>

    <!-- 页面2 -->
    <swiper-item style="background-color: #EAB393; ">
      <scroll-view style="height: 100%;" scroll-y='true'>
        <grid-view type="masonry" cross-axis-count="2" cross-axis-gap="5" main-axis-gap="5">
          <view class='bg-gradual-pink' wx:for="123456789123456789" wx:key="index" style="height: 40px;">
            页面2:索引 {{index}}
          </view>
        </grid-view>
      </scroll-view>
    </swiper-item>
  </swiper>
</view>

(三)wxss代码


/* ----------------内容部分(3-tab页面)---------------------- */
.nav .cu-item.cur {
	border-bottom: 6rpx solid #F15318;
}

(四)wsjs代码

// pages/all/demo.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  
  // 组件的方法列表
  methods: {

    //(3.1)tab头点击
    tabSelect(e) {
      console.log('你已经点了tab头部,索引为:' + e.currentTarget.dataset.id)
      this.setData({
        tabCur: e.currentTarget.dataset.id
      })
    },
    //(3.2)tab滑动事件
    onSwiperChange(e) {
      console.log('你已经滑动了轮播,当前索引id:' + e.detail.current)
      this.setData({
        tabCur: e.detail.current
      })

    }, //end-tab滑动事件

  }
})

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大大大钢琴

开启一个愿望池,许下你愿望吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值