Swiper10.x

1. 简介

Swiper是一个流行的移动端滑动插件,用于创建响应式、触摸滑动的滑块组件。它可以用于创建图片轮播、内容切换、滑动导航等功能。
官网传送阵:Swiper

2. 引入

注意:对于用vue使用Swiper,vue3和vue2对应的Swiper版本不一样

安装: npm install swiper@10.0.0(后面的版本是可以自己修改的)
低版本的可能需要下载一个叫做vue-awesome-swiper的组件

3. 编写组件

       <template> 
        <swiper
            ref="{swiperRef}"
            :slides-per-view="5"  //决定一页有几个轮播图
            :grab-cursor="true"    //鼠标放轮播图上有小手
            :centeredSlides="false"  //轮播图开始在中间位置
            :spaceBetween="30"       //两图之间的间隙
            :navigation="navigation"   //next、prev箭头
            :modules="modules"       //绑定自己的轮播图功能
            class="mySwiper"
        >
          <swiper-slide v-for="(item,index) in teacher" :key="index" class="teacher_photo" @mouseover="mouseover(index)">
            <img :src="item.picture">
          </swiper-slide>
        </swiper>
       </template>
        
    <script>
    import {Navigation,Autoplay} from "swiper/modules"; //功能
    import { Swiper, SwiperSlide } from 'swiper/vue';  //siwper标签
    import 'swiper/swiper-bundle.css';

     
    //自定义名师轮播图左右箭头样式
    const navigation = {
       nextEl: '.swiper-button-next',
       prevEl: '.swiper-button-prev'
    };

    const modules = [Navigation,Autoplay]
      </script>

4. 使用效果

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LD白哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值