小程序选项卡,可左右滑动

wxhtml:

<view class="swiper-tab">

  <view class="tab-item swiper-tab-item {{currentTab==0 ? ‘on‘ : ‘‘}}" data-current="0" bindtap="clickTab">我要取专票</view>

  <view class="tab-item swiper-tab-item {{currentTab==1 ? ‘on‘ : ‘‘}}" data-current="1" bindtap="clickTab">我的发布</view>

</view>

<swiper current="{{currentTab}}" class="swiper" duration="300" bindchange="bindChange"  style="height:{{currentTab==1?Hei+‘rpx‘:‘100%‘}}">

  <swiper-item>我要取专票内容</swiper-item>

  <swiper-item>我的发布内容</swiper-item>

</swiper>

wxss:

.swiper-tab {

  width: 100%;

  border-bottom: 2rpx solid #f5f5f5;

  text-align: center;

  height: 100rpx;

  line-height: 100rpx;

  font-size: 30rpx;

}

.swiper-tab-item {

  display: inline-block;

  width: 50%;

  color: #999;

}

.tab-item {

  flex: 1;

  font-size: 30rpx;

  display: inline-block;

  color: #777;

}

.on {

  color: #4ca835;

  border-bottom: 4rpx solid #4ca835;

}

.swiper {

  display: block;

  height: 100%;

  width: 100%;

}

js:

data: {

  Hei:"",

  currentTab: 0,

}

//滑动切换选项卡

bindChange: function (e) {

  var that = this;

  that.setData({ currentTab: e.detail.current });

},

// 点击切换选项卡

clickTab: function (e) {

  var that = this;

  if (this.data.currentTab === e.target.dataset.current) {

    return false;

  }

   else {

    that.setData({

      currentTab: e.target.dataset.current

    })

  }

},

时间: 2024-07-31 18:39:21

小程序选项卡,可左右滑动的相关文章

关于小程序 scroll-view 左右横向滑动没有效果(无法滑动)问题

小程序组件 scroll-view 中分别有上下竖向滑动和左右横向滑动之分,在这次项目中刚好需要用到横向滑动,但在测试过程中发现横向滑动没有了效果(静止在那里没移动过),经个人调试发现: 1.scroll-view 中的需要滑动的元素不可以用 float 浮动: 2.scroll-view 中的包裹需要滑动的元素的大盒子用 display:flex; 是没有作用的: 3.scroll-view 中的需要滑动的元素要用 dislay:inline-block; 进行元素的横向编排: 4.包裹 sc

微信小程序自制scroll-view横向滑动滚动条

效果图   实现代码 index.wxml <scroll-view scroll-x="true" class="scroll-view-x" style="padding-top:10rpx" scroll-with-animation="true" wx:if="{{tlist[currentTab].secondList}}" scroll-left='0' bindscroll="

超简单实现 微信小程序 选项卡

<view class="swiper-tab"> <view class="swiper-tab-item {{currentTab==index ? 'on' : ''}}" wx:for="{{navbar}}" data-current="{{index}}" wx:key="unique" bindtap="swichNav">{{item}}</

小程序里禁止页面滑动

<view class="modal_bg" catchtouchmove="true" fixed="true" wx:if="{{ modal_show }}"></view> 原文地址:https://www.cnblogs.com/Basu/p/8434665.html

微信小程序学习指南

作者:初雪链接:https://www.zhihu.com/question/50907897/answer/128494332来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 微信小程序正式公测, 张小龙全面阐述小程序,定档1月9日上线(附90分钟演讲全文) ... 前言:新人第一坑,跳坑指南:修改后,必须保存:ctrl+S: 1:官方工具:https://mp.weixin.qq.com/debug/w ... tml?t=1476434678461 2:简易教

微信小程序后台返回大量多余数据的处理

台接口返回一个数组,数组里面N多对象,每个对象里面几十上百条数据,最好玩的是,我只需要每个对象里面的某两个数据.... 类似这种: datas:[   {   id:1000,   name: "帅哥",   title: '...',   b: '...',   d: 0,   f:0,   ....   },   {   id:1001,   name: "美女",   title: '...',   b: '...',   d: 0,   f:0,   ...

微信小程序之选项卡的实现方法

微信小程序里没有自带选项卡组件,但是却带有swiper组件,所以,我们便利用swiper来实现选项卡的功能. 先看效果图: 实现代码: 页面代码: 1 2 3 4 5 6 7 8 9 10 11 <view class="swiper-tab">   <view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="

小程序之选项卡切换(纵向)

选项卡算是小程序中必不可少,大家基本上都会用到的一个功能组件,今天就来分享一个自己做的效果,纵向的一个选项卡 wxml <view class='productNav'> <!-- 左侧 --> <view class='left'> <view class="{{active==0?'selected':'normal'}}" id="0" bindtap='switchNav'>牙齿清洁</view>

【微信小程序】获取轮播图当前图片下标、滑动展示对应的位数、点击位数展示对应图片

业务需求: 3个图片轮番播放,可以左右滑动,点击指示点可以切换图片  index.wxml: 这里使用小程序提供的<swiper>组件autoplay:自动播放interval:自动切换时间duration:滑动动画的时长current:当前所在的页面bindchange:current 改变时会触发 change 事件由于<swiper>组件提供的指示点样式比较单一,另外再自定义指示点的样式 index.wxml : <scroll-view scroll-y="