The use of swiper in uni, display multiple at a time

<view class="title">公益咨询</view>
		<view class="list">
			<swiper class="swiper1">
				<swiper-item v-for="(item,index) in pbgoodlist" :key="index" class="swiperitem">
					<view class="item" v-for="(item1,index1) in item" :key="index1" @tap="goList(item1)">
						<image :src="item1.cover"></image>
						<span>{
    
    {
    
    item1.title}}</span>
					</view>
				</swiper-item>
			</swiper>
		</view>

1. Define pbgoodlist in data: []

classifyList(id){
    
    
				this.api.classifyList ({
    
    
					parentId:id
				})
				.then(res=>{
    
    
					if(id==1){
    
    
						this.pbgoodlist = res.data.data
						var data = this.pbgoodlist
						var list = []
						//一次显示3个
						for (var i = 0, len = data.length; i < len; i += 3) {
    
    
							list.push(data.slice(i, i + 3));
						}
						this.pbgoodlist=[]
						for(var j=0;j<list.length;j++){
    
    
							this.pbgoodlist.push(list[j])
						}
						console.log(this.pbgoodlist);
					}else if(id==2) {
    
    
						this.businesslist = res.data.data
						var data1 = this.businesslist
						var list1 = []
						//一次显示10 个
						for (var i = 0, len = data1.length; i < len; i += 10) {
    
    
							list1.push(data1.slice(i, i + 10));
						}
						this.businesslist=[]
						for(var j=0;j<list1.length;j++){
    
    
							this.businesslist.push(list1[j])
						}
					}
				})
				.catch(err=>{
    
    
					
				})
			},

2. You can slide left and right
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45894929/article/details/111692507