<template>
<view class="home">
<swiper style="height: 100%; width:100%;" :interval="3000" autoplay>
<swiper-item class="swiper-item fl" v-for="(v, i) in dataList" :key="i" :index="i">
<div class="home-item" v-for="(item, index) in v">
<div class="home-item-images">
<image :src="item.cookPhoto" style="height: 100%; width: 100%;">
</div>
<div class="home-item-nameBody">
<p style="width: 100%;">{{ item.cookDish }}</p>
<p style="width: 100%;">{{ item.cookName }}</p>
<p style="width: 100%;">{{ item.cookGrade }}</p>
</div>
</div>
</swiper-item>
</swiper>
</view>
</template>
<script>
export default {
data() {
return {
data: []
}
},
mounted() {},
methods: {},
computed: {
dataList() {
let arr = Array.apply(null, {length: parseInt(this.data.length / 3 + 1)}).map(() => ([]))
this.data.forEach((v, i) => {
arr[parseInt(i / 3)].push(v);
})
arr = arr.filter(item => item.length > 0)
if (arr[0] && !arr[0].length) arr = [];
return arr;
}
},
}
</script>
swiper轮播,根据数据分页展示(一页轮播展示多少内容)
于 2023-03-02 14:17:35 首次发布