vue v-for list数据循环 每3或者(n)个一组

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
          }
        }

  

 

上一篇:推荐系统(三):推荐系统中常见多任务模型MMOE,ESMM,CGC,AITM


下一篇:多任务学习——【RecSys 2020】【腾讯视频】PLE