vue2 + swiper.js

》swiper 使用的 9.2.0版本

<template>
    <div
        v-show="gridInfoList.length > 0"
        class="swiper"
     >
        <div class="swiper-wrapper">
            <GridMember
                v-for="(item, index) in gridInfoList"
                :key="index"
                class="swiper-slide"
                :gridInfo="item"
            />
        </div>
        <div class="swiper-pagination" />
    </div>
</template>
<script lang="javascript">
import Swiper, { Autoplay, Pagination } from 'swiper';
import 'swiper/swiper.scss';
import 'swiper/modules/pagination/pagination.scss';


mounted () {
    // 这里要注意,swiper 容器的类名必须用 swiper
    new Swiper('.swiper', {
        speed: 500,
        spaceBetween: 50,
        autoplay: {
            delay: 5000,
            disableOnInteraction: false,
            pauseOnMouseEnter: true
        },
        /** 
          这里是你需要引入的一些功能,自动轮播、小圆点分页符、左右切换按钮,同时需要引入对应的样式。
          自动轮播不需要单独引入样式
        */
        modules: [Autoplay, Pagination], 
        slidesPerView: 1,
        loop: true,
        pagination: {
            el: '.swiper-pagination',
            type: 'bullets',
            clickable: true
        }
    });
}
</script>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容