微信小程序-Tab标签

拼搏现实的明天。 2022-03-09 15:40 384阅读 0赞

index.wxml

  1. <view class='itemContent'>
  2. <!--标签-->
  3. <view class="swiper-tab">
  4. <view class="swiper-tab-item {
  5. {currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">照片展示</view>
  6. <view class="swiper-tab-item {
  7. {currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">服务说明</view>
  8. </view>
  9. <!--内容-->
  10. <view class="{
  11. {currentTab == 0 ? 'show':'hidden'}}">
  12. <view class='content'>
  13. <view class='msg2'>
  14. 内容1
  15. </view>
  16. </view>
  17. </view>
  18. <view class="{
  19. {currentTab == 1 ? 'show':'hidden'}}">
  20. <view class='content'>
  21. <view class='msg2'>
  22. 内容2
  23. </view>
  24. </view>
  25. </view>
  26. </view>

index.wxss

  1. .itemContent {
  2. margin-top: 20rpx;
  3. background: #fff;
  4. padding-bottom: 120rpx;
  5. }
  6. .swiper-tab {
  7. width: 100%;
  8. text-align: center;
  9. height: 100rpx;
  10. line-height: 100rpx;
  11. display: flex;
  12. flex-flow: row;
  13. justify-content: center;
  14. color: #000;
  15. font-size: 36rpx;
  16. letter-spacing: 2rpx;
  17. margin-bottom: 30rpx;
  18. }
  19. .swiper-tab-item {
  20. color: #000;
  21. }
  22. .swiper-tab-item:first-child {
  23. margin-right: 50rpx;
  24. }
  25. .active {
  26. border-bottom: 10rpx solid #efe29e;
  27. }
  28. .show {
  29. display: block;
  30. }
  31. .hidden {
  32. display: none;
  33. }

index.js

  1. Page({
  2. data: {
  3. currentTab: 0
  4. },
  5. //照片展示 服务说明Tab标签
  6. clickTab: function(e) {
  7. var that = this;
  8. if (this.data.currentTab === e.target.dataset.current) {
  9. return false;
  10. } else {
  11. that.setData({
  12. currentTab: e.target.dataset.current
  13. })
  14. }
  15. },
  16. })

发表评论

表情:
评论列表 (有 0 条评论,384人围观)

还没有评论,来说两句吧...

相关阅读