码迷,mamicode.com
首页 > 其他好文 > 详细

vue使用vue-awesome-swiper插件,实现滚动条组件

时间:2020-04-06 13:54:09      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:scope   port   swiper   vertica   rom   awesome   rop   out   alt   

效果图

技术图片

 

src/components/scroll/index.vue

<template>
    <swiper class="swiper" :options="swiperOption">
    <swiper-slide>
        <!-- 所有内容放在插槽里 -->
        <slot></slot>
    </swiper-slide>
    <div class="swiper-scrollbar" slot="scrollbar"></div>
  </swiper>
</template>

<script>
  import { Swiper, SwiperSlide } from ‘vue-awesome-swiper‘;
  import ‘swiper/css/swiper.css‘;

  export default {
    name: ‘Scrollbar‘,
    title: ‘Scrollbar‘,
    components: {
      Swiper,
      SwiperSlide
    },
    data() {
      return {
        swiperOption: {
          scrollbar: {
            el: ‘.swiper-scrollbar‘,
            hide: true
          },
          direction:‘vertical‘,
          slidesPerView:‘auto‘,
          freeMode:true,
          setWrapperSize:true
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
    .swiper-container{
        width:100%;
        height:100%;
        overflow:hidden;
    }
    .swiper-wrapper{
        height:auto;
    }
    .swiper-slide{
        height:auto;
    }
</style>

 

src/pages/home/index.vue

<template>
    <div class="home">
        <scrollbar>
            <slider />
            <div class="content"></div>

        </scrollbar>
        <!-- 该页面自己的子路由 -->
        <router-view></router-view>
    </div>

</template>

<script>
import Slider from ‘components/slider‘;
import Scrollbar from ‘components/scroll‘;

export default {
    name:"Home",
    components:{
        Slider,   
        Scrollbar    
    }
}
</script>

<style scoped>
    .home{
        width:100%;
        height:100%;
    }
    .content{
        height:1000px;
    }
</style>

 

vue使用vue-awesome-swiper插件,实现滚动条组件

标签:scope   port   swiper   vertica   rom   awesome   rop   out   alt   

原文地址:https://www.cnblogs.com/chenyingying0/p/12641600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!