请问为啥图片显示不了 还有小圆点的问题也显示不了

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

T9FernandoTorres

2020-06-05 18:00:05

<template>

<div class="wrapper">

     <swiper :options="swiperOption">

    <swiper-slide v-for="item in swiperList" :key="item.id"><img class="swiper-img" src="item.imgUrl"></swiper-slide>

    <div class="swiper-pagination "  slot="pagination"></div>

  </swiper>

</div>

</template>


<script>

export default {

    name: 'HomeSwiper',

    data(){

        return{

            swiperOption:{

                pagination:'.swiper-pagination',

                loop:true

            },

            swiperList:[{

                id:'0001',

                imgUrl:"https://imgs.qunarzz.com/sight/p0/1501/89/babe532d89b23ac070bc09dd092dc9b0.water.jpg_710x360_de6badea.jpg"

            },{

                id:'0001',

                imgUrl:"//imgs.qunarzz.com/sight/p75/201211/03/c5e69645fb3de0e193835fbb.jpg_710x360_79a8ab8c.jpg"

            }]

        }

    }

}

</script>


<style lang="stylus" scoped>

    .wrapper >>> .swiper-pagination-bullet-active

        background white !important

    .wrapper

        width 100%

        height 0

        padding-bottom 31.25%

        background #cccccc

        overflow hidden

    .swiper-img

        width 100%

</style>


写回答

1回答

好帮手慕码

2020-06-05

同学你好,解答如下:

1、图片出不来,是因为src应该是动态绑定的:

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

2、小圆点出不来是图片高度的问题:(swiper-container是插件渲染出来的dom元素)

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

图片高度超出了wrapper盒子的padding-bottom值。因为圆点是相对于swiper-container盒子进行定位的,而这个盒子高度是由图片高度撑起来的,超出padding-bottom值部分隐藏了,所以看不到小圆点。建议修改圆点相对于wrapper盒子定位:

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

效果:

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

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

1

0 学习 · 10739 问题

查看课程