element el-carousel 轮播图分页,一页显示n条
html
<el-carousel trigger="click" height="650px" :autoplay='false'>
<el-carousel-item v-for="(item,index) in productRecommendationList" :key="index">
<div class='view'>
<div class="view-item" v-for="(itemList, i) in item" :key="i">
<shop-recommend page-tyep="recommend" :page-data="itemList"
@click.native="itemList.showType?'':clickshoplist('tuijian',itemList)" />
</div>
</div>
</el-carousel-item>
</el-carousel>
js
this.productRecommendationList = res.data.data
let newDataList = []
let current = 0
if(this.productRecommendationList && this.productRecommendationList.length>0){
for(let i = 0; i <= this.productRecommendationList.length - 1; i++){
if(i % 8 !== 0 || i === 0 ){
if(!newDataList[current]){
newDataList.push([this.productRecommendationList[i]])
}else{
newDataList[current].push(this.productRecommendationList[i])
}
}else{
current++
newDataList.push([this.productRecommendationList[i]])
}
}
}
this.productRecommendationList = [...newDataList]