<template>
<div>
<Swiper ref="swiper" v-if="list.length > 0" :autoPlay='true' :showIndicator='true' interval="2500" duration="500">
<Slide @click="clickMe" v-for="(tag,key) in list" :key="key">
<img :src="tag.img" />
</Slide>
</Swiper>
<div><button @click="preve">上一张</button></div>
<div><button @click="next">下一张</button></div>
</div>
</template> <script>
import { Swiper, Slide } from 'vue-swiper-component';
export default {
data() {
return {
list: [
{ img: 'https://qiniu.epipe.cn/5456575529551388672?imageslim&imageView2/1/w/750/h/360' },
{ img: 'https://qiniu.epipe.cn/5430983074181545984?imageslim&imageView2/1/w/750/h/360' },
{ img: 'https://qiniu.epipe.cn/5464226412548325376?imageslim&imageView2/1/w/750/h/360' }
]
}
},
components: {
Swiper,
Slide
},
methods: {
clickMe (index){
console.log(index)
},
preve(){
this.$refs.swiper.prevSlide();
},
next(){
this.$refs.swiper.nextSlide();
} }
} </script> <style>
img {
width: 100%;
} .button {
margin-top: 30px;
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
padding-left: 14px;
padding-right: 14px;
box-sizing: border-box;
font-size: 18px;
text-align: center;
text-decoration: none;
color: #ffffff;
line-height: 2.33333333;
border-radius: 5px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
overflow: hidden;
border-width: 0;
width: 50%;
padding: 0 30px 0 30px;
outline: 0;
-webkit-appearance: none;
background-color: #26a2ff;
} .button:active {
opacity: 0.5;
color: #333;
} .button2 {
margin-top: 100px;
}
</style>

  参考地址

https://github.com/zwhGithub/vue-swiper

使用方法//

npm i vue-swiper-component --save
cnpm i vue-swiper-component --save //国内镜像
import { Swiper, Slide } from 'vue-swiper-component';

components: {
Swiper,
Slide
}
  //加一些参数配置情况
<Swiper v-if="slidesReal.length > 0" :autoPlay='true' :showIndicator='true' interval="2500" duration="500">
<Slide @click="clickMe" v-for="(tag,key) in slidesReal" :key="key">
//添加click事件
</Slide>
</Swiper>

属性 说明 默认
autoPlay 是否自动轮播 true
showIndicator 是否显示轮播的那个点 true
interval 每两次隔多久滚动一次 2500
duration 每次滚动一页需要多久时间 500
 

Swiper 上面还暴露了其他方法,在 Swiper 标签上添加 ref 属性, 例如: <Swiper ref="swiper"></Swiper>

    ✅  this.$refs.swiper.prevSlide(); // 上一张图
   ✅ this.$refs.swiper.nextSlide(); // 下一张图
✅ this.$refs.swiper.slideTo(2); //某一张图

vue 轮播插件使用的更多相关文章

  1. vue轮播插件vue-awesome-swiper

    https://surmon-china.github.io/vue-awesome-swiper/ 第一步安装 npm install vue-awesome-swiper --save 第二部在m ...

  2. 后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件

    后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件 一.总结 一句话总结: vue中的插件的使用和js插件的使用一样的简单,只是vue插件的引入过程有些不同 ...

  3. Javascript和jQuery WordPress 图片轮播插件, 内容滚动插件,前后切换幻灯片形式显示

    用于在有限的网页空间内展示一组产品图片或者照片,同时还有非常吸引人的动画效果.本文向大家推荐12款实用的 jQuery 图片轮播效果插件,帮助你在你的项目中加入一些效果精美的图片轮播效果,希望这些插件 ...

  4. vue轮播,不是只有左右切换的,还有只切换src的

    在项目中,初次接触vue,看了轮播插件vue-swiper等,好多都是左右切换的.个人强迫症比较严重,就要单页切换样式,就手写了一个. 功能:自动轮播,上一页下一页,点击小圆点切换大图.基本轮播要求的 ...

  5. 原生JS实现"旋转木马"效果的图片轮播插件

    一.写在最前面 最近都忙一些杂七杂八的事情,复习软考.研读经典...好像都好久没写过博客了... 我自己写过三个图片轮播,一个是简单的原生JS实现的,没有什么动画效果的,一个是结合JQuery实现的, ...

  6. 多预览小图焦点轮播插件lrtk

    多预览小图焦点轮播插件lrtk // JavaScript Document $(document).ready(function(){ //$('#select_btn li:first').css ...

  7. 推荐:图片轮播插件Nivo Slider

          因为项目需要一款切换样式多一些的轮播插件,不经意找到了NivoSlider,非常好用,比bootstrap要好用,而且样式丰富.值得注意的是,这款插件是在MIT协议下免费的.        ...

  8. PgwSlideshow-基于Jquery的图片轮播插件

    0 PgwSlideshow简介 PgwSlideshow是一款基于Jquery的图片轮播插件,基本布局分为上下结构,上方为大图轮播区域,用户可自定义图片轮播切换的间隔时间,也可以通过单击左右方向按键 ...

  9. 12款经典的白富美型—jquery图片轮播插件—前端开发必备

    图片轮播是网站中的常用功能,用于在有限的网页空间内展示一组产品图片或者照片,同时还有非常吸引人的动画效果.本文向大家推荐12款实用的 jQuery 图片轮播效果插件,帮助你在你的项目中加入一些效果精美 ...

随机推荐

  1. cmd登入mysql的命令不要写分号

    下面是正确的: 下面这个就是错误的 mysqldump同理

  2. 【184】FileZilla 搭建 FTP 及访问

    参考:FileZilla 下载中心 参考:使用FileZilla Server轻松搭建个人FTP服务器 建好后,Windows 访问:Windows徽标键+R打开运行窗口,输入ftp://*** ,* ...

  3. winform 窗体设置成无边框、可拖拽、四周圆角

    最近做一个及时通讯系统的登录界面,现在将界面用到的无边框.可拖拽.四周圆角的方法分享如下: 1.无边框的窗体: 把FormBorderStyle的属性设置为none 2.可拖拽:private Poi ...

  4. E20180324-hm

    popover 弹出框 archive  v. 存档;  n. 档案文件; 档案室;

  5. Codeforces Round #386 (Div. 2)G. New Roads [构造][树]

    题目链接:G. New Roads 题意:给出n个结点,t层深度,每层有a[i]个结点,总共有k个叶子结点,构造一棵树. 分析: 考虑一颗树,如果满足每层深度上有a[i]结点,最多能有多少叶子结点 那 ...

  6. Douglas-Peucker 轨迹压缩算法

    算法的基本思路是:     对每一条曲线的首末点虚连一条直线,求所有点与直线的距离,并找出最大距离值dmax ,用dmax与限差D相比:     若dmax <D,这条曲线上的中间点全部舍去; ...

  7. [App Store Connect帮助]八、维护您的 App(4.1)监控顾客评论:评分与评论概述

    App Store 上的评分与评论 顾客可以按照 1 星至 5 星的级别对您的 App 进行评分.顾客还可为您的 iOS 和 macOS App 撰写评论,但无法为 Apple TVOS App 撰写 ...

  8. 一个 Java 对象到底有多大?

    阅读本文大概需要 2.8 分钟. 出处:http://u6.gg/swLPg 编写 Java 代码的时候,大多数情况下,我们很少关注一个 Java 对象究竟有多大(占据多少内存),更多的是关注业务与逻 ...

  9. python常用的装饰器

    一.为程序添加时间类的装饰器二.验证用户是否等陆 #.为函数添加统计时间的装饰器: import time def timeer(func): def inner(): starttime=time. ...

  10. Python从网页上爬取图片

    在搜索壁纸的时候,想把壁纸保存到本地,一张一张的保存太过麻烦,所以想到用Python来爬取壁纸. 设计思路: 1.首先先去找有壁纸的网页: http://www.acfun.cn/a/ac334521 ...