vue-cli中轮播图vue-awesome-swiper使用方法
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使用方法的更多相关文章
- Bootstrap中轮播图
Bootstrap中轮播图插件叫作Carousel,为了清晰的表明每个标签在这里是什么意思,我把解释写在了下面的代码中. <!-- 以下容器就是整个轮播图组件的整体, 注意该盒子必须加上 cla ...
- element-ui中轮播图自适应图片高度
哈哈,久违了各位.我又回来了,最近在做毕设,所以难免会遇到很多问题,需要解决很多问题,在万能的博友帮助下,终于解决了Element-ui中轮播图的图片高度问题,话不多说上代码. 那个axios的使用不 ...
- reactjs-swiper react轮播图组件基于swiper
react轮播图组件基于swiper demo地址:http://reactjs-ui.github.io/reactjs-swiper/simple.html 1. 下载安装 npm install ...
- iOS中 轮播图放哪最合适? 技术分享
我们知道,轮播图放在cell或collectionViewCell上会影响用户层级交互事件,并且实现起来比较麻烦,现在推出一个技术点:答题思路是:将UIScrollView放在UIView或UICol ...
- JS轮播图动态渲染四种方法
一. 获取轮播图数据 ajax 二.根据数据动态渲染 (根据当前设备 屏幕宽度判断) 1. 准备数据 2. 把数据转换成html格式的字符串 动态创建元素 字符串拼接 模板引擎 框架方法 2.把字符 ...
- vue中轮播图的实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 使用Vue-MUI轮播图失效问题解决案例(在Vue的update中执行)
我使用的是mui+vue,社区关于轮播图失效的问题也有几个.我这边遇到的一个情况是我把所有的东西都写到plusReady事件中会导致轮播图搞死都不动,按照其他问答解决了vue生命周期等等的问题.提出来 ...
- vue自定义轮播图组件 swiper
1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...
- Luffy /3/ 前台主页搭建&轮播图接口
目录 前台主页搭建 components/Homeviwe.vue components/Banner.vue components/Header.vue components/Footer.vue ...
随机推荐
- nginx之升级openssl及自定义nginx版本
favicon.ico浏览器图标配置 favicon.ico 文件是浏览器收藏网址时显示的图标,当客户端使用浏览器问页面时,浏览器会自己主动发起请求获取页面的favicon.ico文件,但是当浏览器请 ...
- 多catch块的代码优化
一.多catch块的代码优化 在写代码时,多行存在不同的异常,使用try catch的话,习惯性的是有多个catch,如下所示: 注意到warning,文字描述如下: Reports identica ...
- 树形dp专题总结
树形dp专题总结 大力dp的练习与晋升 原题均可以在网址上找到 技巧总结 1.换根大法 2.状态定义应只考虑考虑影响的关系 3.数据结构与dp的合理结合(T11) 4.抽直径解决求最长链的许多类问题( ...
- 深度排序模型概述(一)Wide&Deep/xDeepFM
本文记录几个在广告和推荐里面rank阶段常用的模型.广告领域机器学习问题的输入其实很大程度了影响了模型的选择,因为输入一般维度非常高,稀疏,同时包含连续性特征和离散型特征.模型即使到现在DeepFM类 ...
- MySQL索引原理(一)
MySQL索引原理 索引目的 索引的目的在于提高查询效率,可以类比字典,如果要查“mysql”这个单词,我们肯定需要定位到m字母,然后从下往下找到y字母,再找到剩下的sql.如果没有索引,那么你可能需 ...
- [转]iview的render函数用法
原文地址:https://www.jianshu.com/p/f593cbc56e1d 一.使用html的标签(例如div.p) 原生标签用法 二.使用iview的标签(例如Button) iview ...
- 批量实现ssh免密登录
本节索引 场景分析 ssh免密登录 pssh工具批量管理 SHELL自动化脚本 本篇总结 场景分析 作为一个运维工程师,不是每个人工作的环境都想阿里.腾讯那样,动不动就上亿的PV量,上万台服务器.我们 ...
- Scrapy爬虫Demo 爬取资讯分类
爬取新浪网导航页所有下所有大类.小类.小类里的子链接,以及子链接页面的新闻内容. 效果演示图: items.py import scrapy import sys reload(sys) sys.se ...
- Heartbeat took longer than "00:00:01" at "09/06/2019 05:08:08 +00:00".
.netcore在k8s+docker+linux,部署后,偶尔会报这样的警告 Warn:Microsoft.AspNetCore.Server.KestrelHeartbeat took longe ...
- 箱型图Box
箱型图Box 觉得有用的话,欢迎一起讨论相互学习~Follow Me 又称为盒须图.盒式图.盒状图或箱线图,是一种用作显示一组数据分散情况资料的统计图. 箱形图最大的优点就是不受异常值的影响,能够准确 ...