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


    在这里插入图片描述
    html

    	<!-- 轮播 -->
    					<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>
    					<!-- 轮播 -->
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    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;
    		}
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    css

    /* 轮播图 */
    	.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;
    		}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
  • 相关阅读:
    使用python玩转二维码!速学速用!⛵
    基于SSM的租房管理系统
    华清 c++ day3 9月10
    Python函数(一)
    excel每行数据按模板导出一个或多个文件,可插入图片、条形码或二维码
    线性回归之随机梯度下降法(Stochastic Gradient Descent,SGD)
    PG维护笔记
    基于SSH开发网络在线考试系统
    配电室管理系统:现代化电力分配的重要工具
    Nginx搭载负载均衡及前端项目部署
  • 原文地址:https://blog.csdn.net/AAAXiaoApple/article/details/132855998