uview tabs标签与轮播swiper的使用

本文介绍了在使用uviewtabs和轮播swiper时遇到的快速滑动导致swiper卡死的问题。通过将swiper的事件监听器@change替换为@animationfinish,可以有效避免这个问题。示例代码展示了如何在tabs和swiper组件中应用这一修改,确保流畅的滑动体验。
摘要由CSDN通过智能技术生成

uview tabs标签与轮播swiper的使用

如果可左右滑动切换时,由于速度过快可能出现swiper卡死的问题,可将swiper 的@change改为@animationfinish

			<view class="u-tabs-box">
				<!-- 横向滚轴tabs -->
				<scroll-view scroll-x scroll-with-animation class="scroll-tab">
					<!--cTab实际上就是u-tabs,我自己改了样式使用-->
					<cTab :list="items" :is-scroll="true" :current="current" @change="change"></cTab>
				</scroll-view>
			</view>
			<!-- swiper -->
			<swiper class="swiper-box" :current="swiperCurrent" @change="onchange">
				<swiper-item class="swiper-item">
					<scroll-view scroll-y class="scroll-tab" style="height: 100%;width: 100%;" @scrolltolower="onReachBottom1">
						<view class="page-box">
							<uniList class="uniList" v-if='allData.length>0'>
								<uniListItem v-for="(item,index) in allData" :key="index" :title="item.title" :note="item.describe" :thumb="item.imgsrc"
								 thumb-size="lg" :rightText="item.Date"></uniListItem>
							</uniList>
							<view v-else style="height:100vw; display: flex;justify-content: center; align-items: center;">
								<u-empty text="暂无数据" mode="data"></u-empty>
							</view>
							<view v-if='showBT==true' style="display: flex;justify-content: center;">
								<span>没有更多了</span>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onReachBottom1">
						<view class="page-box">
							......
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
/* swiper上一级view的class */
	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
	}
	.scroll-tab {
		width: 100vw;
		height: calc(100vh-86px);
	}
	
	.swiper-box {
		flex: 1;
	}

	.swiper-item {
		height: 100%;
	}

	/* 卡片的高度 */
	.page-box {
		flex: 1;
	}
// tabs改变
			change(index) {
				this.swiperCurrent = index
				this.current = index;
			},
			// swiper改变
			onchange(e) {
				this.swiperCurrent = e.detail.current
				this.current = e.detail.current
			},
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值