轮播图,swiper使用
背景:
最近接到一个需求,重写首页,需要用到轮播图。
但是轮播图只用两张图,此为前提。
本想直接用ElementUI的走马灯,但是只用两张图的情况下,走马灯不能循环播放,只能来回播放,公司的UI小姐姐说这样不专业,所以用了swiper。
正文:
一年前用过swiper,但早忘了。我说一下这次使用的过程。
1.装包
npm install vue-awesome-swiper --save
2.引入
// require styles
import 'swiper/dist/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
3.使用
<swiper :options="swiperOption">
<!-- slides -->
<swiper-slide>
<img src="./1.png" alt="1" />
</swiper-slide>
<swiper-slide>
<img src="./2.png" alt="2" />
</swiper-slide>
<!-- Optional controls -->
<div class="swiper-pagination" slot="pagination"></div>
<!-- <div class="swiper-button-prev" slot="button-prev"></div>
<div class="swiper-button-next" slot="button-next"></div> -->
</swiper>
data() {
return {
// 轮播图参数
swiperOption: {
//滑动速度
speed: 800,
// // 指针形状
// grabCursor : true,
//循环
loop: true,
//自动播放
autoplay: {
// 自动切换的时间间隔,单位ms
delay: 1500,
// 用户操作swiper之后,是否禁止autoplay
disableOnInteraction: false,
},
// 分页器
pagination: {
el: '.swiper-pagination',
// 点击控制Swiper切换
clickable :true,
}
}
}
},
components: {
swiper,
swiperSlide
}
.container {
width: 100%;
overflow: hidden;
height: 500px;
// 轮播图样式
.swiper-container {
height: 100%;
.swiper-slide {
img {
width: 100%;
height: 100%;
}
}
}
}
4.效果

后续
后来我又看elementui,两张图还是不能循环,但是两张图,复制一下就成了四张图。
就可以循环了,然后,操作按钮之类的,可以根据elementui提供的回调函数修改。
轮播图,swiper使用的更多相关文章
- ReactNative新手学习之路04 组件化开发轮播图swiper支持安卓和IOS
react native 新手之路04 组件化开发轮播图swiper支持安卓和IOS npm install react-native-carousel --save git 地址Properties ...
- 微信小程序的轮播图swiper问题
微信小程序的轮播图swiper,调用后,怎样覆盖系统的 点,达到自己想要的效果 不多说,先上一图望大家多给意见: 这个是效果图: 微信小程序效果图就成这样子: <view class=" ...
- React Native 之轮播图swiper组件
注释:swiper组件是第三方组件 所以在使用之前应该先在命令行安装,然后将第三方的模块引入(第三方模块地址:https://github.com/leecade/react-native-swipe ...
- angularjs指令实现轮播图----swiper
'use strict'; angular.module('app').directive('swipersLbt',swipers); swipers.$inject = ['$timeout']; ...
- 微信小程序之视图容器(swiper)组件创建轮播图
一.视图容器(Swiper) 1.swiper:滑块视图容器 微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/swi ...
- 微信小程序之 Swiper(轮播图)
1.逻辑层 mine.js // pages/mine/mine.js Page({ /** * 页面的初始数据 */ data: { /*轮播图 配置*/ imgUrls: [ 'http://im ...
- vue2 使用 swiper 轮播图效果
第一步.先安装swiper插件 npm install swiper@3.4.1 --save-dev 第二步.组件内引入swiper插件 import Swiper from 'swiper' im ...
- vue2.0 + vux (五)api接口封装 及 首页 轮播图制作
1.安装 jquery 和 whatwg-fetch (优雅的异步请求API) npm install jquery --save npm install whatwg-fetch --save 2. ...
- 微信小程序3D轮播图
<!-- 轮播图 --> <swiper previous-margin='50px' next-margin='50px' bindchange="swiperChang ...
- 【云开发】10分钟零基础学会做一个快递查询微信小程序,快速掌握微信小程序开发技能(轮播图、API请求)
大家好,我叫小秃僧 这次分享的是10分钟零基础学会做一个快递查询微信小程序,快速掌握开发微信小程序技能. 这篇文章偏基础,特别适合还没有开发过微信小程序的童鞋,一些概念和逻辑我会讲细一点,尽可能用图说 ...
随机推荐
- Cursor使用
Cursor是一款AI 代码编辑器,官网地址为https://www.cursor.com/,直接在官网下载安装即可,基于VS Code二次开发而来,之所以没有采用插件方式,在官方网站上给出的答案是某 ...
- Polly+HttpClientFactory
Polly 在.Net Core中有一个被.Net基金会认可的库Polly,它一种弹性和瞬态故障处理库,可以用来简化对服务熔断降级的处理. Polly的策略主要由"故障"和&quo ...
- WSL2 使用 code . 命令打开文件夹时,出现 "Unable to establish SSL connection. ERROR: Failed to download..."
1. 背景 在 wsl2 里开发一个小项目,之前一直使用功能正常. 今天按以往的流程(打开 wsl2(ubuntu) 终端,进入到指定文件夹目录下,输入 code . 命令,在 vscode 中打开该 ...
- 软件逆向之OD
OD全称OllyDbg ,是一种具有可视化界面的 32 位汇编-分析调试器.和IDA不同之处在于可以动态调试软件功能,可以有效的去分析程序构成. 以下软件讲解均以吾爱破解中的OD进行讲解.软件下载 打 ...
- 站点监控工具之uptime-kuma
github: https://github.com/louislam/uptime-kuma [安装] docker: docker run -d --restart=always -p 3001: ...
- Phpstorm之快捷键
常用快捷键 1.ctrl+alt+s 快速打开setting系统设置 2.CTRL+/ 单行注释/取消注释 CTRL+SHIFT+/ 块状注释/取消块状注释 3.方法体上面打入'/**' 再按回车键 ...
- TortoiseGit之私钥配置
1.使用git命令生成公钥和私钥 ssh-keygen -t rsa -C "git邮箱账号" 三次回车,即可在~/.ssh/ 生成密钥对 id_rsa id_rsa.public ...
- php-fpm常见错误
1. WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf' # cd /usr/loc ...
- CudaSPONGE高性能GPU分子模拟
技术背景 CudaSPONGE是基于CUDA C开发的一款纯GPU分子动力学模拟软件,具有模块化和高性能的特点.官方基本介绍内容如下: 分子动力学(Molecular Dynamics, MD)模拟是 ...
- ARTHAS 使用
1.概述 ARTHAS是阿里巴巴 出品的一款java监控工具,本文介绍以下他的基本使用方法. 2.基本操作 2.1 启动 java -jar arthas-boot.jar 2.2 基础命令 命令 说 ...