1.首先通过npm安装vue-awesome-swiper,我在项目中用的是2.6.7版本

npm install vue-awesome-swiper@2.6.7 –save

2. 在main.js中引入

import VueAwesomeSwiper from 'vue-awesome-swiper'

import 'swiper/dist/css/swiper.css'

Vue.use(VueAwesomeSwiper)

3.实现轮播图

  1. <template>
  2.  <div class="wrapper">
  3.  <swiper :options="swiperOption" v-if="showSwiper" ref="mySwiper" >
  4.     <!-- slides -->
  5.     <swiper-slide v-for="item of list" :key="item.id">
  6.        <img class="swiper-img" :src="item.imgUrl"/>
  7.     </swiper-slide>
  8.     <div class="swiper-pagination" slot="pagination"></div>
  9.   </swiper>
  10.   </div>
  11. </template>
  12.  
  13. <script>
  14.     export default {
  15.         name:"HomeSwiper",
  16.         props:{
  17.           list:Array
  18.         },
  19.         data (){
  20.            return{
  21.             swiperOption:{
  22.                pagination:".swiper-pagination",
  23.                autoplay: 2000,
  24.                loop:true,
  25.                paginationClickable: true,
  26.                observer:true,
  27.                observeParents:true
  28.             }
  29.  
  30.           }
  31.         } ,
  32.          computed: {
  33.           showSwiper () {
  34.           return this.list.length
  35.         }
  36.       }
  37.     }
  38.  
  39. </script>
  40.  
  41. <style lang="stylus" scoped>
  42.   .wrapper >>> .swiper-pagination-bullet-active
  43.     background:#fff
  44.   .wrapper
  45.     overflow:hidden
  46.     width:100%
  47.     height 0
  48.     padding-bottom:31.25%
  49.     background:#eee
  50.     .swiper-img
  51.        width:100%
  52. </style>

vue-awesome-swiper实现轮播图的更多相关文章

  1. 微信小程序之 Swiper(轮播图)

    1.逻辑层 mine.js // pages/mine/mine.js Page({ /** * 页面的初始数据 */ data: { /*轮播图 配置*/ imgUrls: [ 'http://im ...

  2. Swiper实现轮播图效果

    为了实现轮播图(carousel)效果或左右滑动显示不同的内容,我们采用Swiper来实现. 需要引入swiper.min.css和swiper.min.js,文件可从https://github.c ...

  3. 微信小程序-swiper(轮播图)抖动问题

    ps:问题 组件swiper(轮播图)真机上不自动滚动 一直卡在那里抖动 以前遇到这个问题,官方一直没有正面回复.就搁置了,不过有大半年没写小程序了也没去关注,今天就去看了下官方文档,发觉更新了点好东 ...

  4. vue上的简单轮播图

    好久没写轮播图了,今天在vue上写了个超简单的,效果还ok. .moveLeft{position:relative;right:ZOOMpx;transition:all 1s;} 原理是滚动时利用 ...

  5. (网页)swiper.js轮播图插件

    Swiper4.x使用方法 1.首先加载插件,需要用到的文件有swiper.min.js和swiper.min.css文件.可下载Swiper文件或使用CDN. <!DOCTYPE html&g ...

  6. vue渐变淡入淡出轮播图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. 手机端用swiper组件 轮播图设置后右侧出现空白 及 部分手机浏览器打开网页空白

    我的方法是设置内容css overflow:hidden;width:100%; ok. 之前搜到一个方法也可以,就是设置css height: auto;overflow-y: scroll; 但是 ...

  8. angularjs中使用轮播图指令swiper

    我们在angualrjs移动开发中遇到轮播图的功能 安装 swiper  npm install --save swiper   或者 bower install --save swiper 引入文件 ...

  9. swiper轮播图(逆向自动切换类似于无限循环)

    swiper插件轮播图,默认的轮播循序是会从右向左,第一张,第二张,第三张,然后肉眼可见是的从第三张从左到右倒回第一张,这样就会有些视觉体验不高, ,不过还是能够用swiper本身的特性更改成无限循环 ...

  10. React Native 之轮播图swiper组件

    注释:swiper组件是第三方组件 所以在使用之前应该先在命令行安装,然后将第三方的模块引入(第三方模块地址:https://github.com/leecade/react-native-swipe ...

随机推荐

  1. IDEA的git密码修改

    问题: 如果你办公的电脑是同事用过,在每次提交git的时候都显示是他的名字.想要修改提交git用户名密码. 但是博客idea 修改Git密码和账号方法所示方法无效.且操作系统是win10.(其他操作系 ...

  2. Kubernetes公开应用程序

    pod丢失之后,怎样让程序正常工作. service的概念和作用 标签 Pods 是有生命周期的.当一个工作节点死后,运行在该节点上的pods也会丢失.然后,通过创建新的pods来保持应用程序运行,R ...

  3. kvm磁盘io优化以及性能测试以及与物理机对比

    ubuntu下kvm的磁盘io性能优化步骤 1.virsh shutdown wcltest2 2.virsh edit wcltest2 <driver name='qemu' type='q ...

  4. Asp.net Core 添加 EF 工具并执行初始迁移错误解决方法(Add-Migration Initial---Build failed.)

    1.问题: 首次在ASP.NET Core项目中使用Code First模式的Entity Framework框架,在添加EF工具并做初始化迁移(perform initial migration), ...

  5. Luogu P4478 [BJWC2018]上学路线 卢卡斯+组合+CRT

    首先,从$(0,0)$走到$(n,m)$的方案数是$ C_{n+m}^n$,可以把走的方向看作一种序列,这个序列长$ n+m$ ,你需要从中任取$n$个位置,让他向右走: 然后就是如何处理不能走的点: ...

  6. HDU-2588-GCD (欧拉函数)

    The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the ...

  7. Linux Shell命令系列(3)

    11. chown命令 “chown”命令就是改变文件拥有者和所在用户组.每个文件都属于一个用户组和一个用户.在你的目录下,使用"ls -l",你就会看到像这样的东西.root@t ...

  8. Python Class __init__ __del__ 构造,析构过程解析【转】

    转载自: http://blog.csdn.net/bbdxf/article/details/25774763 最近学习<Python参考手册>即<Learning Python& ...

  9. 三节点Hadoop集群搭建

    1. 基础环境搭建 新建3个CentOS6.5操作系统的虚拟机,命名(可自定)为masternode.slavenode1和slavenode2.该过程参考上一篇博文CentOS6.5安装配置详解 2 ...

  10. Zookeeper崩溃恢复过程(Leader选举)

    1. 崩溃恢复 a). leader选择过程可以保证新leader是ZXID最大的节点 b). ZAB协议确保丢弃那些只在leader上被提出的事务,场景 leader发出PROPOSAL收到ACK, ...