vue使用swiper

本文介绍了如何在Vue项目中使用Swiper组件,包括使用的开发环境(VSCode)、调试工具(Chrome),以及如何查阅Swiper API文档。文章详细讲解了配置过程,特别提到了采用的Swiper版本为5.4.5,并分享了处理图片显示的技巧。
摘要由CSDN通过智能技术生成

1.编译器: vscode
2.调试浏览器chrome

swiperAPI文档:link

配置环境

npm install swiper@5.x vue-awesome-swiper --save

5.x下载的swiper的版本为5.4.5

<template>
  <div id="app">
    <swiper :options="swiperOption" id="swiper-container">
      <swiper-slide><img src="./assets/images/index01.jpg"></swiper-slide>
      <swiper-slide><img src="./assets/images/index02.jpg"></swiper-slide>
      <!--分页器-->
      <div class="swiper-pagination" slot="pagination"></div>
      <!--前进后退需要手动添加点击事件-->
      <div class="swiper-button-prev" slot="button-prev" @click="prev"></div>
      <div class="swiper-button-next" slot="button-next" @click="next"></div>
    </swiper>
  </div>
</template>
<script>
import {Swiper, SwiperSlide} from 'vue-awesome-swiper'
import 'swiper/css/swiper.css'
export default {
  name: 'App',
  data: function () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination',
          clickable: true
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev'
        },
        loop: true,
        autoplay: {
          delay: 1000,
          disableOnInteraction: false
        },
        speed: 1000
      }
    }
  },
  components: {
    Swiper,
    SwiperSlide
  }
}
</script>
<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
#swiper-container{
  width: 600px;
  height: 300px;
}
img{
  width: 600px;
  height: 300px;
}
</style>

我图片网上找的,所以用了img来设置了下大小

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

ZzDIY

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

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

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

打赏作者

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

抵扣说明:

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

余额充值