zoukankan      html  css  js  c++  java
  • vue轮播图中间大两头小

    <template>
      <div v-if="items.length" class="full-page-slide-wrapper">
        <swiper :options="swiperOption" ref="mySwiper">
          <!-- slides -->
          <template v-for="item in items">
            <swiper-slide v-if="item.bannerImageUrl" :key="item.pid">
              <img @click="toTopic(item)" :src="item.bannerImageUrl" alt>
            </swiper-slide>
          </template>
          <div class="swiper-pagination" slot="pagination"></div>
        </swiper>
      </div>
    </template>
    
    <script type="text/ecmascript-6">
    import 'swiper/dist/css/swiper.css'
    import { swiper, swiperSlide } from 'vue-awesome-swiper'
    import { getFirstConfig } from '@/services/main.service'
    const COMPONENT_NAME = 'pull-page-slide'
    export default {
      name: COMPONENT_NAME,
      data () {
        return {
          items: [],
          defaultIndex: 0,
          swiperOption: {
            direction: 'horizontal',
            loop: true,
            autoplay: 5000,
            slidesPerView: 'auto',
            centeredSlides: true,
            spaceBetween: 10,
            // 如果需要分页器
            pagination: {
              el: '.swiper-pagination',
              bulletActiveClass: 'slide_dot_active',
              bulletClass: 'slide_dot'
            }
          }
        }
      },
      mounted () {
        this.getConfig()
      },
      components: {
        swiper,
        swiperSlide
      },
      methods: {
        handleClick () {
    
        },
        toTopic (item) {
          if (item.topicId) {
            this.$router.push({ name: 'topic.detail', params: { id: item.topicId } })
          }
        },
        async getConfig () {
          let { datas } = await getFirstConfig().catch(e => console.error(e))
          this.items = datas
        }
      }
    }
    </script>
    <style lang="scss">
    .full-page-slide-wrapper {
       100%;
      height: 140px;
      background: white;
      box-sizing: content-box;
      padding-top: 15px;
      margin-top: 10px;
      position: relative;
      overflow: hidden;
      .swiper-container {
         100%;
        height: 100%;
        .swiper-wrapper {
          display: flex;
          align-items: center;
        }
        .swiper-slide {
           calc(100% - 50px);
          border-radius: 5px;
        }
        .swiper-slide-prev {
          height: 90% !important;
        }
        .swiper-slide-next {
          height: 90% !important;
        }
      }
      img {
        object-fit: fill;
        height: 100%;
         100%;
        border-radius: 5px;
      }
      .slide_dot {
        display: inline-block;
        margin: 5px;
         3px;
        height: 3px;
        background-color: #f2f2f2;
        border-radius: 50%;
        opacity: 0.5;
      }
      .swiper-pagination {
        bottom: 0;
      }
      .slide_dot_active {
        display: inline-block;
         7px;
        height: 3px;
        border-radius: 5px;
        background: white;
        opacity: 1;
      }
    }
    </style>
    
    

    图例

  • 相关阅读:
    objective-C 自定义对象归档的实现
    D3D游戏编程系列(一):DXLib的介绍
    再谈 retain,copy,mutableCopy(官方SDK,声明NSString都用copy非retain)
    uva 11292 Dragon of Loowater (勇者斗恶龙)
    【iOS开发】iOS7 兼容及部分细节
    QMenu的个性化定制
    基于Token的WEB后台认证机制
    Lua简易入门教程
    char,short ,int ,long,long long,unsigned long long数据范围
    用Kibana和logstash快速搭建实时日志查询、收集与分析系统
  • 原文地址:https://www.cnblogs.com/raind/p/10721932.html
Copyright © 2011-2022 走看看