Vant轮播图库
<template>
<van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
<van-swipe-item class="my-swipeitem"><slot></slot></van-swipe-item>
</van-swipe>
</template>
<script>
import { Swipe, SwipeItem } from "./Swipe";
export default {
name: "Swipe",
components: {
Swipe,
SwipeItem,
},
}
</script>
<style scoped>
.my-swipe .van-swipe-item {
color: #fff;
font-size: 20px;
line-height: 150px;
text-align: center;
background-color: #39a9ed;
}
</style>
<template>
<Swipe>
<slot v-for="item in swipebannar"><img :src="item.image" alt="" /></slot>
</Swipe>
</template>
<script>
import Swipe from "../../../components/content/swipe/Swipe.vue";
export default {
name: "HomeSwipe",
components: {
Swipe,
},
props: {
swipebannar: {
type: Array,
default() {
return [];
}
}
}
}
</script>
<style scoped>
.my-swipeitem img {
width: 100%;
height: 100%;
}
</style>
谁能指导下怎么把第一个Vant轮播图的ui库,封到第二个Swipe组件里面不。
我把数据传到vant库里面是能正常显示的,但是我自己封的轮播图竖着排一排,也不滚动。
这是因为插槽的位置只有一个,你遍历扔进去三个,而且还在父组件中又弄了插槽
可以改成,Swipe通过props接收一个数组,内部遍历生成多个van-swipe-item,父组件把swipebannar传入
自己封的有报错吗