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

效果图

 

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'return {
        swiperOption: {
          scrollbar: {
            el: '.swiper-scrollbar'true
          },direction:'vertical'
        }
      }
    }
  }
</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  {
    name:"Home"
    .home{
        width:100%;
    }
    .content{
        height:1000px;
    }
</style>

 

相关文章

https://segmentfault.com/a/1190000022018995 https://www....
ES6 (ECMAScript 6)中的模块是一个包含 JavaScript 代码的...
from https://mp.weixin.qq.com/s/-rc1lYYlsfx-wR4mQmIIQQ V...
D:\Temp&gt;npm init vite@latest vue3study --temp...
文章浏览阅读1.2k次。最近自己从零撸起的甘特图组件需要子组...
文章浏览阅读3.3k次,点赞3次,收藏16次。静默打印是什么?简...