1 npm 安装

  1. npm install vue-awesome-swiper --save

2在所用的组件中引入

  1. import 'swiper/dist/css/swiper.css'
  2. import { swiper, swiperSlide } from 'vue-awesome-swiper'

3 在components中进行注册

  1. components:{
  2.   swiper,
  3. swiperSlide
  4. },

4 在vue-cli中组件的template中进行使用

  1. <template>
  2. <swiper :options="swiperOption">
  3. <swiper-slide v-for="(item,index) in slideImages">
  4. <a href="#" target="_blank"><img :src="item.imageUrl" /><span class="title">{{item.title}}</span></a>
  5. </swiper-slide>
  6. <div class="swiper-pagination swiper-pagination-bullets" slot="pagination"></div>
  7. </swiper>
  8. </template>

5 对轮播图的属性进行配置

  1. data(){
  2. return {
  3. swiperOption: {
  4. autoplay: {//自动播放
  5. delay: 2500,
  6. disableOnInteraction: false
  7. },
  8. pagination: {//分页
  9. el: '.swiper-pagination',
  10. clickable: true,
  11. renderBullet(index, className) {//自定义分页的按钮
  12. return `<span class="${className} swiper-pagination-bullet-custom"></span>`
  13. }
  14. }
  15. }
  16. }
  17. },

其中按钮的样式的css代码如下:

  1. .swiper-pagination-bullet-custom {
  2. width: 9px;
  3. height: 9px;
  4. text-align: center;
  5. line-height: 20px;
  6. font-size: 12px;
  7. color: #000;
  8. opacity:;
  9. border-radius:;
  10. background: #fff;
  11. }
  12. .swiper-pagination-bullet-custom.swiper-pagination-bullet-active {
  13. color: #fff;
  14. background: #a11703;
  15. }

这样子轮播图就可以自动轮播啦!!!

遇到的问题:

如果要实现无缝轮播,需要在swiperOption中添加如下代码

  1. swiperOption: {
  2. autoplay: {
  3. delay: 2500,
  4. disableOnInteraction: false
  5. },
  6. loop:true,//环装轮播
  7. }

同时还要在<swiper>添加v-if控制环装轮播,否则不起作用

代码如下:

  1. <swiper :options="swiperOption" ref="mySwiper" v-if="swiperList.length>1">
  2. <!--用v-if控制loop环状轮播,否则不起作用-->
  3. <swiper-slide v-for="(item,index) in swiperList"
  4. :index="index" :key="item.index" class="swiper_box">
  5. <div class="goodsimg">
  6. <img :src=imgURL+item.goodsPicture alt="" />
  7. </div>
  8. </swiper-slide>
  9. </swiper>

vue-cli中轮播图vue-awesome-swiper使用方法的更多相关文章

  1. Bootstrap中轮播图

    Bootstrap中轮播图插件叫作Carousel,为了清晰的表明每个标签在这里是什么意思,我把解释写在了下面的代码中. <!-- 以下容器就是整个轮播图组件的整体, 注意该盒子必须加上 cla ...

  2. element-ui中轮播图自适应图片高度

    哈哈,久违了各位.我又回来了,最近在做毕设,所以难免会遇到很多问题,需要解决很多问题,在万能的博友帮助下,终于解决了Element-ui中轮播图的图片高度问题,话不多说上代码. 那个axios的使用不 ...

  3. reactjs-swiper react轮播图组件基于swiper

    react轮播图组件基于swiper demo地址:http://reactjs-ui.github.io/reactjs-swiper/simple.html 1. 下载安装 npm install ...

  4. iOS中 轮播图放哪最合适? 技术分享

    我们知道,轮播图放在cell或collectionViewCell上会影响用户层级交互事件,并且实现起来比较麻烦,现在推出一个技术点:答题思路是:将UIScrollView放在UIView或UICol ...

  5. JS轮播图动态渲染四种方法

    一. 获取轮播图数据  ajax 二.根据数据动态渲染 (根据当前设备 屏幕宽度判断) 1. 准备数据 2. 把数据转换成html格式的字符串 动态创建元素 字符串拼接 模板引擎 框架方法 2.把字符 ...

  6. vue中轮播图的实现

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

  7. 使用Vue-MUI轮播图失效问题解决案例(在Vue的update中执行)

    我使用的是mui+vue,社区关于轮播图失效的问题也有几个.我这边遇到的一个情况是我把所有的东西都写到plusReady事件中会导致轮播图搞死都不动,按照其他问答解决了vue生命周期等等的问题.提出来 ...

  8. vue自定义轮播图组件 swiper

    1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...

  9. Luffy /3/ 前台主页搭建&轮播图接口

    目录 前台主页搭建 components/Homeviwe.vue components/Banner.vue components/Header.vue components/Footer.vue ...

随机推荐

  1. .NET总结--泛型与泛型集合,应用场景

    泛型优点 1.提高代码复用性,代码简洁直观 2.直接存储数据类型免去数据类型之间得隐式转换 3.免去拆箱装箱过程,提高效率 4.数据类型安全,存储时会验证是否对应该类型 泛型集合 一. ArrayLi ...

  2. nuxt项目服务端渲染应用部署、使用pm2守护进程及遇到的问题处理

    服务端渲染应用部署应该先编译构建,然后再启动 Nuxt 服务,可通过以下两个命令来完成: nuxt build nuxt start 我们已经在pakage.json里配置好script命令 { &q ...

  3. sourceforge文件下载过慢

    sourceforge文件下载过慢,可以用下面网址镜像下载, http://sourceforge.mirrorservice.org 按搜索到的项目的英文字母依次查询,如http://sourcef ...

  4. java并发编程(一)线程状态 & 线程中断 & 线程间的协作

    参考文章: Java线程的5种状态及切换:http://blog.csdn.net/pange1991/article/details/53860651 线程的5种状态: 1. 新建(NEW):新创建 ...

  5. TensorFlow2.0初体验

    TF2.0默认为动态图,即eager模式.意味着TF能像Pytorch一样不用在session中才能输出中间参数值了,那么动态图和静态图毕竟是有区别的,tf2.0也会有写法上的变化.不过值得吐槽的是, ...

  6. Shell命令行提示定制

    /******************************************************************************* * Shell命令行提示定制 * 说明 ...

  7. linux中nohup 与 & 的区别

    Linux/Unix下,通常只有守护进程可在脱离终端的情况下能继续执行,而普通进程在关闭终端时会因收到SIGHUP信号(挂起信号)而退出.当终端退出后,由该终端启动的后台程序自动退出. 若想命令在后台 ...

  8. 避免git clone和push时每次都需要输入用户名和密码

    有三种方式解决git clone时每次都需要输入用户名和密码, 1. SSH免密方式 使用git bash ssh-keygen或puttygen.exe生成公钥. 2. 配置全局开机存储认证信息 下 ...

  9. 超简易简易PHP爬虫

    利用CURL和DOMDocument.通过xpath筛选数据,实现的简易PHP爬虫 <?php header('Content-type: text/plain; charset=utf-8') ...

  10. Python 精选文章

    操作Excel,通过宏调用Pyhton(VBA调Python) 第一个django项    https://www.jianshu.com/p/45b07d8cd819