微信小程序> 微信小程序之Tab切换

微信小程序之Tab切换

浏览量:648 时间: 来源:小小雪花儿

wxml:

view

view class='swiper-tab'

view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab"1/view

view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab"2/view

view class="swiper-tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="clickTab"3/view

view class="swiper-tab-item {{currentTab==3?'active':''}}" data-current="3" bindtap="clickTab"4/view

/view

swiper class='swiper' current='{{currentTab}}' duration="300" bindchange="bindchange"

view

swiper-item

scroll-view scroll-y="true"

view class='gaodu'第一页/view

view class='gaodu'第一页/view

view class='gaodu'第一页/view

view class='gaodu'第一页/view

view class='gaodu'显示/view

/scroll-view

/swiper-item

/view

swiper-item

scroll-view scroll-y="true"

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

view class='gaodu'第二页/view

/scroll-view

/swiper-item

swiper-item

scroll-view scroll-y="true"

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

view class='gaodu'第三页/view

/scroll-view

/swiper-item

swiper-item

scroll-view scroll-y="true"

view class='gaodu'第四页/view

view class='gaodu'第四页/view

view class='gaodu'第四页/view

view class='gaodu'第四页/view

view class='gaodu'第四页/view

view class='gaodu'第四页/view

view class='gaodu'第四页/view

view class='gaodu'1第四页/view

view class='gaodu'0/view

/scroll-view

/swiper-item

/swiper

/view

wxss:

.swiper-tab{

display: flex;

height: 80rpx;

line-height: 80rpx;

width: 100%;

position:fixed;

top:0;

z-index: 100;

background: #fff;

}

.swiper-tab-item{

flex: 1;

text-align: center;

border-bottom: 1rpx solid #eee;

}

.active{

color: blue;

position: relative;

}

.swiper-tab-item.active:after{

content: "";

display: block;

height: 6rpx;

width: 60rpx;

background: #4675F9;

position: absolute;

bottom: 0;

left: 65rpx;

border-radius: 16rpx;

}

.swiper{

width: 100%;

height: 100%;

display: flex;

position: fixed;

top:80rpx;

}

scroll-view{

width: 100%;

height: 93%;/*动态高度*/

}

.gaodu{

height: 100rpx;

background: rgb(196, 248, 255);

text-align: center;

line-height: 100rpx;

border-bottom: 1rpx solid #4675F9;

}

js:

Page({

data: {

currentTab: 0 //预定的位置

},

//点击滑动

bindchange: function (e) {

let that = this;

that.setData({

currentTab: e.detail.current

})

},

//点击切换,滑块index赋值

clickTab: function (e) {

let that = this;

if (that.data.currentTab === e.currentTarget.dataset.current) {

return false;

} else {

that.setData({

currentTab: e.currentTarget.dataset.current

})

}

}

})

 

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

最新资讯

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎