微信小程序实现水平垂直滚动
短信预约 -IT技能 免费直播动态提醒
本文实例为大家分享了微信小程序实现水平垂直滚动的具体代码,供大家参考,具体内容如下
要点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
});
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程网。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341