7-9章节 给swiper标签加入v-if="showSwiper"后swiper显示问题
来源:7-10 Vue项目首页 - 首页父子组组件间传值
阿联酱
2018-06-26
<template> <div class="wrapper"> <swiper :options="swiperOption" v-if="showSwiper"> <!-- slides --> <swiper-slide v-for="item of swiperList" :key="item.id"> <img class="swiper-img" :src="item.imgUrl"/> </swiper-slide> <!-- Optional controls --> <div class="swiper-pagination" slot="pagination"></div> </swiper> </div> </template> <script> export default { name: 'HomeSwiper', props: { swiperList: Array }, data () { return { swiperOption: { pagination: '.swiper-pagination', loop: true, autoplay:true, speed:1000 } } }, computed: { showSwiper () { return this.swiperList.length } } } </script> <style lang="stylus" scoped> .wrapper >>> .swiper-pagination-bullet-active background: #fff .wrapper overflow: hidden width: 100% height: 0 padding-bottom: 31.5% background: #eee .swiper-img width: 100% </style>
写回答
1回答
-
Dell
2018-06-26
什么问题
022018-06-28
相似问题