亲宝软件园·资讯

展开

微信小程序水平垂直滚动 微信小程序实现水平垂直滚动

火腿肠烧烤大赛冠军 人气:0
想了解微信小程序实现水平垂直滚动的相关内容吗,火腿肠烧烤大赛冠军在本文为您仔细讲解微信小程序水平垂直滚动的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:微信小程序水平滚动,微信小程序垂直滚动,微信小程序滚动,下面大家一起来学习吧。

要点swiper内部套scroll-view

注意:

1.scroll竖直滚动高度不能给百分比要给px/rpx
2.swiper内部item posiiton定位高度100%
3.swiper高度要给定值
4.如果横向滚动也要给水平的宽度

代码

xml

<swiper class="tab-box" current="{{currentTab}}" duration="300" bindchange="switchTab">
 <swiper-item class="tab-content">
 <scroll-view class="scroll-height" scroll-y="true" scroll-with-animation="{{true}}">
  <view class="cont">
  <view class="jira-card" wx:for="{{jiraArray}}" wx:for-index="idx" wx:for-item="itemJira" wx:key="idx">
  <card itemJira="{{itemJira}}" data-item="{{itemJira}}" bindtap="goDetail"></card>
  </view>
  </view>
 </scroll-view>

 </swiper-item>
 <swiper-item class="tab-content">
 <scroll-view class="scroll-height" scroll-y="true" scroll-with-animation="{{true}}">
  <view class="cont">
  <view class="jira-card" wx:for="{{jiraArray}}" wx:for-index="idx" wx:for-item="itemJira" wx:key="idx">
  <card itemJira="{{itemJira}}" data-item="{{itemJira}}" bindtap="goDetail"></card>
  </view>
  </view>
 </scroll-view>
 </swiper-item>
 </swiper>

<swiper class="tab-box" current="{{currentTab}}" duration="300" bindchange="switchTab">
 <swiper-item class="tab-content">
 <scroll-view class="scroll-height" scroll-y="true" scroll-with-animation="{{true}}">
  <view class="cont">
  <view class="jira-card" wx:for="{{jiraArray}}" wx:for-index="idx" wx:for-item="itemJira" wx:key="idx">
  <card itemJira="{{itemJira}}" data-item="{{itemJira}}" bindtap="goDetail"></card>
  </view>
  </view>
 </scroll-view>

 </swiper-item>
 <swiper-item class="tab-content">
 <scroll-view class="scroll-height" scroll-y="true" scroll-with-animation="{{true}}">
  <view class="cont">
  <view class="jira-card" wx:for="{{jiraArray}}" wx:for-index="idx" wx:for-item="itemJira" wx:key="idx">
  <card itemJira="{{itemJira}}" data-item="{{itemJira}}" bindtap="goDetail"></card>
  </view>
  </view>
 </scroll-view>
 </swiper-item>
</swiper>

wxss

.tab-box{
 height: 1040rpx;
}
.scroll-height {
height: 1040rpx;
}

js

myAudit(){
 this.setData({
 currentTab:0,
 })
},
myInitiate(){
 this.setData({
 currentTab:1,
 // jiraArray:[]
 })
},
switchTab(event){
 var cur = event.detail.current;
 var singleNavWidth = this.data.windowWidth / 5;
 this.setData({
 currentTab: cur,
 navScrollLeft: (cur - 2) * singleNavWidth
 });
}

加载全部内容

相关教程
猜你喜欢
用户评论