html:
<template style="width: 100%; height: 100%">
<el-carousel
indicator-position="none"
arrow="hover"
style="width: 100%; height: 100%"
>
<el-carousel-item
class="el-car-item"
v-for="(a, index) in resultData"
:key="index"
>
<AnalyseAI
class="top-img"
v-for="(imgList, index2) in a"
:key="index2"
:data="imgList"
></AnalyseAI>
</el-carousel-item>
</el-carousel>
</template>
js:
let newDataList = [];
let current = 0;
if (this.resultData && this.resultData.length > 0) {
for (let i = 0; i <= this.resultData.length - 1; i++) {
if (i % 4 !== 0 || i === 0) {
// 不够四个
if (!newDataList[current]) {
newDataList.push([this.resultData[i]]);// 每四个建立一个新数组
} else {
newDataList[current].push(this.resultData[i]);
}
} else {
current++;
newDataList.push([this.resultData[i]]); // 一页方四个走下一页
}
}
}
this.resultData = [...newDataList];
轮播:一次四个
于 2023-04-24 13:40:08 首次发布