vue2 里边使用 swiper2
找过了很多轮播图插件,我都不会用,还是回到swiper2吧。。。
npm install swiper@2.7.6 --save-dev
封装成一个组件
<template>
<div class="lunbo" :class="name" :style="{height: h+'rem'}">
<div class="swiper-container" v-if="type==1">
<div class="fuck swiper-wrapper">
<div class="swiper-slide" v-for="item in banners">
<img :src="item">
</div>
</div>
<div class="swiper-pagination"></div>
</div> <div class="swiper-container" v-if="type==2">
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="item in banners">
<a :href="item.turnUrl"><img :src="item.img"></a>
</div>
</div>
<div class="swiper-pagination"></div>
</div> <div class="swiper-container" v-if="type==3">
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="item in banners">
<a :href="item.turnUrl">{{item.content}}</a>
</div>
</div>
<div class="swiper-pagination" v-show="false"></div>
</div>
</div>
</template> <script>
import 'swiper/dist/idangerous.swiper.css'
import Swiper from 'swiper/dist/idangerous.swiper.js'
export default {
props: ['banners','type','h','name'],
data () {
return {}
},
watch: {
},
mounted: function () {
let vm = this;
new Swiper('.'+vm.name+' .swiper-container', {
loop: true,
autoplay: 4000,
updateOnImagesReady : true,
autoplayDisableOnInteraction : false,
pagination: '.'+vm.name+' .swiper-pagination',
})
}
}
</script>
<style>
/*没有分页器 加scoped不会错 */
a{
cursor: pointer;
}
.lunbo{
margin: 0 auto;
position: relative;
}
.swiper-container{
height: 100%;
}
.swiper-slide{
height: 100%;
color: white;
}
.swiper-pagination {
position: absolute;
z-index: 20;
bottom: 10px;
width: 100%;
text-align: center;
}
/*分页器的样式*/
.swiper-pagination-switch {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 8px;
background: #6d6df8;
margin: 0 5px;
opacity: 0.8;
border: 1px solid #fff;
cursor: pointer;
}
.swiper-active-switch {
background: #fff;
}
</style>
vue2 里边使用 swiper2的更多相关文章
- 越来越受欢迎的Vue想学么,90后小姐姐今儿来教你
摘要:Vue的相关技术原理成为了前端岗位面试中的必考知识点,掌握 Vue 对于前端工程师来说更像是一门"必修课". 本文原作者为尹婷,擅长前端组件库研发和微信机器人. 我们发现, ...
- Vue2.0 + Element-UI + WebAPI实践:简易个人记账系统
最近正在学习Vue2.0相关知识,正好近期饿了么桌面端组件Element-UI发布,便动手做了一款简易个人记账系统,以达到实践及巩固目的. 1.开发环境 Win10 + VS2015 + Sqlser ...
- 适用初学者:vue2.0构建单页应用最佳实战
参考:https://segmentfault.com/a/1190000007630677 自己gitHub项目地址:https://github.com/shixiaoyanyan/vue-wor ...
- Vue2全家桶之二:vue-router(路由)详细教程,看这个就够了
作者:东西里本文转载于:https://www.jianshu.com/p/514c7588e877来源:简书 转载仅供自己日后看方便. 由于Vue在开发时对路由支持的不足,于是官方补充了vue- ...
- 重开Vue2.0
目录: 内容: 一.Vue内部指令: 1.v-if v-else&v-show v-if与v-show都是选择性显示内容的指令,但是二者之间有区别: 1.v-if:判断是否加载,在需要的时候加 ...
- cordova打包vue2(webpack)android、ios app
使用cordova打包vue2(webpack)app for android ios1.vue项目通过vue-cli脚手架建立项目,使用webpack进行打包,下边是一整套命令. #npm 版本最好 ...
- Vue2.0 【第二季】第8节 Component 父子组件关系
目录 Vue2.0 [第二季]第8节 Component 父子组件关系 第8节 Component 父子组件关系 一.构造器外部写局部注册组件 二.父子组件的嵌套 Vue2.0 [第二季]第8节 Co ...
- Vue2.0 【第一季】第3节 v-for指令:解决模板循环问题
目录 Vue2.0 [第一季] 第3节 v-for指令:解决模板循环问题 第三节 v-for 指令 一.基本用法: 二.排序 三.对象循环输出 Vue2.0 [第一季] 第3节 v-for指令:解决模 ...
- Vue2.0 【第四季】第1节 实例入门-实例属性
目录 Vue2.0 [第四季]第1节 实例入门-实例属性 第1节 实例入门-实例属性 一.Vue和Jquery.js一起使用 二.实例调用自定义方法 Vue2.0 [第四季]第1节 实例入门-实例属性 ...
随机推荐
- SQL修改日期类型字段为字符串类型
select * from test1 --添加行 ) --将转换格式后的数据放到列中 ) --删除老的字段 alter table test1 drop column startdate --修改字 ...
- [物理学与PDEs]第5章习题6 各向同性材料时强椭圆性条件的等价条件
在线性弹性时, 证明各向同性材料, 强椭圆性条件 (5. 6) 等价于 Lam\'e 常数满足 $$\bex \mu>0,\quad \lm+2\mu>0. \eex$$ 证明: (1) ...
- SSH框架之Hibernate《一》
hibernate的基础入门 一:hibernate和ORM的概念部分 1.1hibernate概述: Hibernate框架是当今主流的Java持久层框架之一 ...
- 原生js封装cookie获取、设置及删除
使用cookie(key,value,options) 参数key,value,options(可选) function cookie(key,value,options){ if(typeof va ...
- 目标检测网络之 YOLOv3
本文逐步介绍YOLO v1~v3的设计历程. YOLOv1基本思想 YOLO将输入图像分成SxS个格子,若某个物体 Ground truth 的中心位置的坐标落入到某个格子,那么这个格子就负责检测出这 ...
- HttpUtility.UrlEncode编码重写
1. 某些系统方法,例如.NET系统方法HttpUtility.UrlEncode会将‘=’编码成‘%3d’,而不是%3D,导致加密签名通不过验证,请开发者注意检查. 2.Java 1.3和早期版本中 ...
- JSP起源
JSP起源: 在很多动态网页中,绝大部分内容都是固定不变的,只有局部内容需要动态产生和改变. 如果使用Servlet程序来输出只有局部内容需要动态改变的网页,其中所有的静态内容也需要程序员用Java程 ...
- 两个同级div重叠的情况
一个div使用了position,自身脱离了文本流,另一个顶上去.
- POJ 2398 Toy Storage(叉积+二分)
Description Mom and dad have a problem: their child, Reza, never puts his toys away when he is finis ...
- Fast RCNN 中的 Hard Negative Mining
 Fast RCNN 中将与 groud truth 的 IoU 在 [0.1, 0.5) 之间标记为负例, [0, 0.1) 的 example 用于 hard negative mining. ...