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节 实例入门-实例属性 ...
随机推荐
- ZooKeeper 概述
ZooKeeper:分布式应用程序的分布式协调服务 ZooKeeper:是用于分布式应用程序的分布式开源协调服务 可以简单理解:ZooKeeper = 文件系统 + 通知机制 从设计模式角度理解:Zo ...
- 无连接运输的UDP、可靠数据传输原理、面向连接运输的TCP
由[RFC 768]定义的UDP只是做了运输协议能够做的最少工作.除了复用/分解功能极少量的差错检测外,它几乎没有对IP增加别的东西.如果应用程序开发人员选择UDP而不是TCP,则该应用程序差不多就是 ...
- SpringBoot系列: 制作Docker镜像的全过程
本文主要参考了 https://segmentfault.com/a/1190000016449865 , 感谢作者的付出. 另外, 在本文中, 演示了Windows+Maven+Docker To ...
- [物理学与PDEs]第3章习题6 Lagrange 坐标下的一维理想磁流体力学方程组的数学结构
试讨论 Lagrange 形式下的一维理想磁流体力学方程组 (5. 33)-(5. 39) 的类型. 解答: 由 (5. 33), (5. 39) 知 $$\bex 0=\cfrac{\p p}{\p ...
- VIM --使用进阶 -- 插件篇 -- YouCompleteMe -- nerdtree
系统:ubuntu: 资源:https://github.com/ 其他:想了解都要哪些好用的插件,推荐大家读 http://blog.csdn.net/mergerly/article/detail ...
- python中的__len__,__getitem__ __setitem__ __delitem__ __contains__
可变集合需要实现: __len__ __getitem__ __setitem__ __delitem__不可变集合需要实现: __len__ __getitem__ __len__:返回 ...
- Vue.js 技术揭秘(学习) vue流程
new Vue() _init() mergeOptions $watch --> new Watch vm._render 生成VNode create diff patch vm._upda ...
- 迅为iTOP-4418/6818开发板-驱动-实现GPIO扩展
实现 GPIO 扩展,先弄清楚“复用”的概念,将调用这些 GPIO 的驱动去掉配置,重新编译,加到自己的驱动中,就可以实现扩展的 GPIO 的输入和输出.另外必须要先看文档“迅为iTOP-4418开发 ...
- php 默认保几位小数,末尾为0去掉
计算保留几位小数,末位为0舍去 // 计算 默认保留1位小数 protected function getSprintf($value,$count,$digit = 1) { $num = 0; i ...
- 抓包工具tcpdump用法说明
tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. 不带任何选项的tcpdump,默认会抓取第一个网络接口,且只有将tcpdump进程终止才会停止抓包. 例如: ...