循环轮播显示有问题,还有如果把.wrapper里的样式取消注释,小圆点就不显示了

来源:2-6 Vue项目首页 - 首页轮播图(2)

Ever__

2020-08-03 14:21:08

http://img.mukewang.com/climg/5f27ac7f090d1a7819200882.jpg

<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

同学你好,可能由于图片比例不对,建议先使用源码中提供的图片测试下。

如果还有问题,将你修改后的代码粘贴过来,老师帮助同学测试下,祝学习愉快~

0

Ever__

提问者

2020-08-03

http://img.mukewang.com/climg/5f27d75409fa336a16270622.jpg

0

好帮手慕慕子

2020-08-03

同学你好,遍历循环的是swiper-slide,而不是对swiper循环,建议修改:

http://img.mukewang.com/climg/5f27c4c509a778cf11410336.jpg

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

http://img.mukewang.com/climg/5f27c4ec090487cf07380379.jpg

结果:

http://img.mukewang.com/climg/5f27c50609bd220d04340167.jpg

如果我的回答帮助到了你,欢迎采纳,祝学习愉快~

0
hver__
h 老师,第一个解决了,但是第二个取消注释后小圆点就不见了。图片也会显示不全
h020-08-03
共1条回复

0 学习 · 10739 问题

查看课程