1 npm 安装

 npm install vue-awesome-swiper --save

2在所用的组件中引入

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

3 在components中进行注册

 components:{
  swiper,
swiperSlide
},

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

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

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

 data(){
return {
swiperOption: {
autoplay: {//自动播放
delay: 2500,
disableOnInteraction: false
},
pagination: {//分页
el: '.swiper-pagination',
clickable: true,
renderBullet(index, className) {//自定义分页的按钮
return `<span class="${className} swiper-pagination-bullet-custom"></span>`
}
}
}
}
},

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

 .swiper-pagination-bullet-custom {
width: 9px;
height: 9px;
text-align: center;
line-height: 20px;
font-size: 12px;
color: #000;
opacity:;
border-radius:;
background: #fff;
}
.swiper-pagination-bullet-custom.swiper-pagination-bullet-active {
color: #fff;
background: #a11703;
}

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

遇到的问题:

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

  swiperOption: {
autoplay: {
delay: 2500,
disableOnInteraction: false
},
loop:true,//环装轮播
}

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

代码如下:

 <swiper :options="swiperOption" ref="mySwiper" v-if="swiperList.length>1">
<!--用v-if控制loop环状轮播,否则不起作用-->
<swiper-slide v-for="(item,index) in swiperList"
:index="index" :key="item.index" class="swiper_box">
<div class="goodsimg">
<img :src=imgURL+item.goodsPicture alt="" />
</div>
</swiper-slide>
</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. Nginx目录文件列表显示

    项目中使用了tomcat,Nginx,测试阶段,生产阶段经常会有些bug需要调查.需要有些日志管理工具,在没有ELK的情况下,可以通过配置nginx来实现基本的日常查看.不需要登录到Linux服务器上 ...

  2. Segment fault 常见原因

    [https://blog.csdn.net/qq_22238021/article/details/79872978] 本质原因在于:程序访问了非法的地址 1.引用空指针 2.野指针 3.访问越界 ...

  3. Tocmat 统计tomcat进程内的线程数

    获取tomcat进程pid ps -ef | grep tomcat 统计该tomcat进程内的线程个数 ps -Lf  558899 | wc -l

  4. count(*) count(1) count(字段) 区别

    count(*) count(1) count(字段) 区别 count(*)和count(字段) count(*)和count(字段)使用的目的是不一样的,在必须要使用count(字段)的时候还是要 ...

  5. 洛谷 P1969 积木大赛(NOIP2013)

    题目描述春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是hi. 在搭建开始之前,没有任何积木(可以看成n ...

  6. Redis禁用部分危险命令(keys/flushdb等)

    在redis.conf文件[SECURITY]区域配置: 1.禁用命令: rename-command KEYS "" rename-command FLUSHALL " ...

  7. 【C++】C++中的容器解析

    目录结构: contents structure [-] 顺序容器 顺序容器的种类 顺序容器的操作 容器操作可能使迭代器失效 Vector容器的增长机制 容器适配器 关联容器 关联容器的分类 关联容器 ...

  8. 解决docx4j 变量替换 由于变量存在样式式或空白字符 导致替换失败问题

    参考文章:https://blog.csdn.net/qq_35598240/article/details/84439929 使用docx4j进行变量替换时 变量(形如:${变量})必须是无格式的, ...

  9. [转]跨域问题(CORS / Access-Control-Allow-Origin)

    原文链接:https://blog.csdn.net/xcbeyond/article/details/84453832 1.前言 最近在项目中,调用Eureka REST接口时,出现了CORS跨越问 ...

  10. Java基础 awt Frame 窗体的大小不可调

        JDK :OpenJDK-11      OS :CentOS 7.6.1810      IDE :Eclipse 2019‑03 typesetting :Markdown   code ...