uniapp 轮播列表左右滑动,滑动到中间放大

html

javascript 复制代码
	<!-- 轮播 -->
					<view class="heade">
						<swiper class="swiper" display-multiple-items='3' circular='true' previous-margin='1rpx'
							next-margin='1rpx' current='0' @change="swiperChange" >
							<block v-for="(item,index) in list" :key='index'>
								<swiper-item class="sitem">
									<view class="swiper-item" :class="{current:index==currentIndex}">
										<text class="u-f-s-26 weight-500 u-color-1D1">初级会员{{index}}--{{currentIndex}}</text>
										<view class="u-color-FE6 weight-600 u-f-s-40 u-m-t-16"><text class="u-f-s-24 weight-400">¥</text> 99.00</view>
										<view class="u-color-646 u-f-s-20 u-m-t-16">有效期30天</view>
									</view>
								</swiper-item>
							</block>
						</swiper>
					</view>
					<!-- 轮播 -->

javascript

javascript 复制代码
export default {
	data() {
			return {
				currentIndex: 1,
				list:[1,2,3,4,5,6,7,8,9,10],
				
			}
		},
	methods:{
		swiperChange(event) {
			let a = 1;
			if (event.detail.current == (Number(this.list.length)- 1))  {
				// 滑动到最后一个时,  currentIndex 和 数组的下标 index 相等
				a = -(Number(this.list.length)- 1)
			}
			this.currentIndex = event.detail.current + a;
		}
	}
}

css

javascript 复制代码
/* 轮播图 */
	.heade {
			height: 300rpx;
			position: relative;
		}
	 
		.sitem {
			box-sizing: border-box;
			display: flex;
			justify-content: center;
			align-items: center;
		}
	 
		.swiper {
			width: 100vw;
			position: absolute;
			bottom: 0;
			left: 0;
		}
		.current {
			transform: scale(1.15);
			position: absolute;
			background: #FFF7F0 !important;
			border: 2rpx solid #FFAA9A !important;
			top: 6rpx;
			left: 0rpx;
			right:0rpx;
			z-index: 10;
			transition: all 0.2s ease-in 0s;
			border-radius: 16rpx;
		}
		uni-swiper-item {
			overflow: inherit;
		}
		.swiper-item {
			box-sizing: border-box;
			position: relative;
			background: #FCFCFF;
			border-radius: 16rpx;
			border: 2rpx solid #DFE4E9;
			padding: 24rpx;
			text-align: center;
		}
相关推荐
八月林城7 小时前
echarts在uniapp中使用安卓真机运行时无法显示的问题
android·uni-app·echarts
哈贝#7 小时前
vue和uniapp聊天页面右侧滚动条自动到底部
javascript·vue.js·uni-app
iOS阿玮9 小时前
苹果2024透明报告看似更加严格的背后是利好!
uni-app·app·apple
邹荣乐12 小时前
微信小程序动态tabBar实现:基于自定义组件,灵活支持不同用户角色与超过5个tab自由组合
前端·微信小程序·uni-app
不吃糖葫芦313 小时前
App使用webview套壳引入h5(三)——解决打包为app后在安卓机可物理返回但是在苹果手机无法测滑返回的问题
uni-app·webview
半兽先生16 小时前
uniapp微信小程序视频实时流+pc端预览方案
微信小程序·uni-app·音视频
胡斌附体1 天前
uniapp路由跳转toolbar页面
小程序·uni-app·switch·路由·type·uview-ui
阿諪諪1 天前
在VSCode中开发一个uni-app项目
ide·vscode·uni-app
发现你走远了1 天前
『uniapp』把接口的内容下载为txt本地保存 / 读取本地保存的txt文件内容(详细图文注释)
开发语言·javascript·uni-app·持久化保存
lqj_本人1 天前
鸿蒙OS&UniApp结合机器学习打造智能图像分类应用:HarmonyOS实践指南#三方框架 #Uniapp
机器学习·uni-app·harmonyos