循环轮播显示有问题,还有如果把.wrapper里的样式取消注释,小圆点就不显示了
来源:2-6 Vue项目首页 - 首页轮播图(2)
Ever__
2020-08-03 14:21:08

<template>
<div class="wrapper">
<swiper :options="swiperOption" v-for="item of swiperList" :key="item.id">
<!-- slides -->
<swiper-slide>
<img :src="item.imgUrl" alt="" class="img-list">
</swiper-slide>
<!-- Optional controls -->
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>
<script>
export default {
name: 'HomeSwiper',
data () {
return {
swiperOption: {
pagination: '.swiper-pagination'
},
swiperList: [{
id: '0001',
imgUrl: 'https://cdn.pixabay.com/photo/2014/07/30/02/00/iceberg-404966__340.jpg'
}, {
id: '0002',
imgUrl: 'https://cdn.pixabay.com/photo/2018/03/12/20/07/maldives-3220702__340.jpg'
}, {
id: '0003',
imgUrl: 'https://cdn.pixabay.com/photo/2015/01/08/15/48/creek-593146__340.jpg'
}]
}
}
}
</script>
<style lang="stylus" scoped>
.wrapper >>> .swiper-pagination-bullet-active
background :#fff
// .wrapper
// overflow :hidden
// width :100%
// height :0
// padding-bottom :32.05%
// background-color #CCC
.img-list
width :100%
height :2.34rem
</style>3回答
好帮手慕慕子
2020-08-03
同学你好,可能由于图片比例不对,建议先使用源码中提供的图片测试下。
如果还有问题,将你修改后的代码粘贴过来,老师帮助同学测试下,祝学习愉快~
Ever__
提问者
2020-08-03

好帮手慕慕子
2020-08-03
同学你好,遍历循环的是swiper-slide,而不是对swiper循环,建议修改:

另,将下图所示css代码,取消注释

结果:

如果我的回答帮助到了你,欢迎采纳,祝学习愉快~
相似问题
回答 2
回答 1