vue 轮播插件使用
<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 轮播插件使用的更多相关文章
- vue轮播插件vue-awesome-swiper
https://surmon-china.github.io/vue-awesome-swiper/ 第一步安装 npm install vue-awesome-swiper --save 第二部在m ...
- 后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件
后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件 一.总结 一句话总结: vue中的插件的使用和js插件的使用一样的简单,只是vue插件的引入过程有些不同 ...
- Javascript和jQuery WordPress 图片轮播插件, 内容滚动插件,前后切换幻灯片形式显示
用于在有限的网页空间内展示一组产品图片或者照片,同时还有非常吸引人的动画效果.本文向大家推荐12款实用的 jQuery 图片轮播效果插件,帮助你在你的项目中加入一些效果精美的图片轮播效果,希望这些插件 ...
- vue轮播,不是只有左右切换的,还有只切换src的
在项目中,初次接触vue,看了轮播插件vue-swiper等,好多都是左右切换的.个人强迫症比较严重,就要单页切换样式,就手写了一个. 功能:自动轮播,上一页下一页,点击小圆点切换大图.基本轮播要求的 ...
- 原生JS实现"旋转木马"效果的图片轮播插件
一.写在最前面 最近都忙一些杂七杂八的事情,复习软考.研读经典...好像都好久没写过博客了... 我自己写过三个图片轮播,一个是简单的原生JS实现的,没有什么动画效果的,一个是结合JQuery实现的, ...
- 多预览小图焦点轮播插件lrtk
多预览小图焦点轮播插件lrtk // JavaScript Document $(document).ready(function(){ //$('#select_btn li:first').css ...
- 推荐:图片轮播插件Nivo Slider
因为项目需要一款切换样式多一些的轮播插件,不经意找到了NivoSlider,非常好用,比bootstrap要好用,而且样式丰富.值得注意的是,这款插件是在MIT协议下免费的. ...
- PgwSlideshow-基于Jquery的图片轮播插件
0 PgwSlideshow简介 PgwSlideshow是一款基于Jquery的图片轮播插件,基本布局分为上下结构,上方为大图轮播区域,用户可自定义图片轮播切换的间隔时间,也可以通过单击左右方向按键 ...
- 12款经典的白富美型—jquery图片轮播插件—前端开发必备
图片轮播是网站中的常用功能,用于在有限的网页空间内展示一组产品图片或者照片,同时还有非常吸引人的动画效果.本文向大家推荐12款实用的 jQuery 图片轮播效果插件,帮助你在你的项目中加入一些效果精美 ...
随机推荐
- less 语法
1 变量 less的变量使用@开头 1.1 demo @colorRed:red; @colorBlue:blue; .demo{ color:@colorRed; background-color: ...
- HardFault_Handler 输出日志信息
之前文章说了原理,这里把最终实现的代码总结: IAR void hard_fault_handler_c (unsigned int * hardfault_args) { unsigned int ...
- 【193】◀▶ PowerShell 官方资料索引
Microsoft.PowerShell.Core 模块 Windows PowerShell 核心 Cmdlet Windows PowerShell 核心函数 Windows PowerShell ...
- (转) SQL Server中 ldf 文件过大的解决方法
原文地址:http://blog.itpub.net/35489/viewspace-616459/ 在SQL Server中经常遇到事务日志变大的情况,除了将数据库设置为“自动收缩”外,还可以使用下 ...
- UVa 11401 Triangle Counting (计数DP)
题意:给定一个数 n,从1-n这些数中任意挑出3个数,能组成三角形的数目. 析:dp[i] 表示从1-i 个中任意挑出3个数,能组成三角形的数目. 代码如下: #pragma comment(link ...
- bzoj 3528 [Zjoi2014]星系调查【树链剖分+数学】
参考:https://www.cnblogs.com/zhuohan123/p/3698852.html 首先,根据点到直线距离公式 \[ d=\frac{kx_0-y_0+b}{\sqrt{k^{2 ...
- [POI2011]Temperature
Description The Byteotian Institute of Meteorology (BIM) measures the air temperature daily. The mea ...
- (五)Python面向对象编程
根据廖雪峰老师的python教程写一些学习总结! 面向对象编程 面向对象编程--Object Oriented Programming,简称OOP,是一种程序设计思想.OOP把对象作为程序的基本单元, ...
- 题解报告:hdu 1203 I NEED A OFFER!(01背包)
Problem Description Speakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了.要申请国外的任何大学,你都要交纳一定的申请费用 ...
- ORA-14074: partition bound must collate higher than that of the last partition
There is a error happen in crotab: CREATE parttion report ORA-14074:ORA-14074: partition bound must ...