template
<van-swipe class="my-swipe-list" :autoplay="3000" indicator-color="#067EEA"> <van-swipe-item v-for="(item,index) in listTemp" :key="index"> <van-row> <van-col :span="8" v-for="(cell,i) in item" :key="i"> <img :src="cell.pic" alt=""> <p v-html="cell.title">{{cell.title}}</p> <p>{{cell.content}}</p> </van-col> </van-row> </van-swipe-item> </van-swipe>
computed代码
computed:{ listTemp:function(){ let index =0; let count = 3; let arrTemp = []; let experts = this.experts; for(let i=0;i<this.experts.length;i++){ index = parseInt(i/count); if (arrTemp.length <= index) { arrTemp.push([]); } arrTemp[index].push(experts[i]) } return arrTemp } }