uniapp卡片式轮播图

使用原生的swiper组件标签

<swiper style="height:240rpx" class="swiper-tall" :autoplay="true" :interval="3000" :duration="500" circular='true'
	:display-multiple-items="4" current='0' @change="partSwiperChange">
	<swiper-item v-for="(list,i) in 6" :key="i">
		<view class='swiper-item gswGoods' data-type="goods" :data-id="list.id" :data-index="i">
			<view class="img-content u-flex u-row-between u-flex-col"
						:class="[ partcurrentIndex === i || partcurrentIndexA === i?'active':'un-active']">
				<view class="top">
					¥<span>{{swiper.money[i]}}</span>
				</view>
				<view class="bottom">
					{{swiper.discount[i]}}
				</view>
			</view>
		</view>
	</swiper-item>
</swiper>

动态绑定类,当目标项为当年项,添加过渡动画。

@change绑定卡片滑动事件,当前项n+1滑动,当走到最后一页,继续循环

partSwiperChange: function(event) {
	this.partcurrentIndex = event.detail.current + 1
	this.partcurrentIndexA = event.detail.current + 2
	if (event.detail.current == 6 - 2) {
		this.partcurrentIndexA = 6 - 1
		this.partcurrentIndexA = 0
	}
	if (event.detail.current == 6 - 1) {
		this.partcurrentIndex = 0
		this.partcurrentIndexA = 1
	}
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值