小程序选项卡小Demo,可滑动控制

思绪
1.选项卡使用scroll-view,实现可以滑动控制效果;
2.使用current控制选项卡标题和内容的统一,实现同步操作;
3.winHeight 这个是我最常用的var calc = clientHeight * rpxR - 440; 440这个值是你所不需要计算的高度值,取决于你除内容之外的高度;
wxml文件

<view class="pinConDet"> <view class=\'title\'>标题</view> <view class=\'con\'> <scroll-view scroll-x="true" class="tab-h" scroll-left="{{scrollLeft}}" class=\'tabBox\'> <view class="tab-item {{currentTab==0?\'active\':\'\'}}" data-current="0" bindtap="swichNav">选项1</view> <view class="tab-item {{currentTab==1?\'active\':\'\'}}" data-current="1" bindtap="swichNav">选项2</view> </scroll-view> <swiper class="tab-content" current="{{currentTab}}" duration="300" bindchange="switchTab" style="height:{{winHeight}}rpx"> <swiper-item> <scroll-view scroll-y="true" class="scoll-h" > <view class="title1"> 选项卡1内容 </view> </scroll-view> </swiper-item> <swiper-item> <scroll-view scroll-y="true" class="scoll-h" > <view class="title1"> 选项卡2内容 </view> </scroll-view> </swiper-item> </swiper> </view> </view>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwfzzy.html