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 图片轮播效果插件,帮助你在你的项目中加入一些效果精美 ...
随机推荐
- 《Image Generation with PixelCNN Decoders》论文笔记
论文背景:Google Deepmind团队于2016发表在NIPS上的文章 motivation:提出新的image generation model based on pixelCNN[1]架构. ...
- 我的JSP中文编码解决方案
虽然以前就知道编码问题,但是一直没有遇到问题,以前用asp.net和php的时候,感觉很自然地写程序,没怎么特别处理编码问题,这回改用java写,真心被恶心到了. 进行了一番查阅学习后,终于搞明白了一 ...
- Github个人主页不显示提交记录的问题
最近发现自己连续三天在github上的提交没显示在个人主页上,一番搜索后终于发现原来是因为没有把git的配置改过来,提交的代码时使用了不同的email. https://code.bradymower ...
- 解决Linux与Windows压缩解压中文文件名乱码(转载)
转自:http://crazyfeng.com/linux-windows-compress-chinese-filename.html 由于Linux与Windows编码问题,使用Zip Tar 压 ...
- ssi,服务器端包含,<include file="">
一.什么是SSI ssi,全称Server Side Include,中文名,服务器端包含. SSI (Server Side Includes)是HTML页面中的指令,在页面被提供时由服务器进行运算 ...
- CodeForces E. Goods transportation【最大流+dp最小割】
妙啊 首先暴力建图跑最大流非常简单,s向每个i连流量为p[i]的边,每个i向t连流量为s[i]的边,每个i向j连流量为c的边(i<j),但是会又T又M 考虑最大流=最小割 然后dp求最小割,设f ...
- JavaScript 入门案例
四. JavaScript 入门案例 在看本节之前,笔者建议您先看 JavaScript 基础篇 https://www.cnblogs.com/IT-LFP/p/10945884.html 1. ...
- head first python /chapter7 web(python 3 转 python 2.7)
前言 书中使用的是python3,我这里使用的是python2.7 Web 的目录树 webapp/ ├── cgi-bin │ ├── athletelist.py │ ├── athletemod ...
- 转 SQLPLUS中SQL换行执行
权声明:本文为博主原创文章,未经博主允许不得转载. 正常情况下,在SQLPLUS中输入命令时,可以换行,但不能有空格,否则不能执行,会直接返回到SQL>下.但通过命令设置可以实现语句换行时允许有 ...
- 转】MongoDB 自动分片 auto sharding
原博文出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/page/4/ 感谢! MongoDB 自动分片 auto shard ...