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节 实例入门-实例属性 ...
随机推荐
- qsort()函数详解
一 写在开头1.1 本节内容学习C语言中的qsort()函数. 二 qsort()2.1 函数原型 void qsort( void *base, size_t nmemb, size_t size, ...
- 第二节:重写(new)、覆写(overwrite)、和重载(overload)
一. 重写 1. 关键字:new 2. 含义:子类继承父类中的普通方法,如果在子类中重写了一个和父类中完全相同的方法,子类中会报警告(问是否显式的隐藏父类的中的方法),如果在子类中的方法前加上new关 ...
- 利用git提交代码
一.首先需要下载git 查看电脑是否安装git,打开终端,输入git,回车如果输出如下,则代表已安装了git 如果未安装,则会输出: 按照提示输入:sudo apt-get install git即可 ...
- CapsNet胶囊网络(理解)
0 - 背景 Geoffrey Hinton是深度学习的开创者之一,反向传播等神经网络经典算法发明人,他在去年年底和他的团队发表了两篇论文,介绍了一种全新的神经网络,这种网络基于一种称为胶囊(caps ...
- 在右键菜单中加入BitLocker重新上锁功能
当使用BitLocker给磁盘上锁后,可以通过命令:manage-bde -lock d: -forcedismount 将已经解锁的磁盘重新上锁,如果觉得每次都通过命令行写命令很麻烦,那可以通过修改 ...
- 【原创】大叔经验分享(43)logstash设置jdbc_default_timezone后报错
logstash6.6.0-6.6.2版本使用jdbc input plugin时如果设置了jdbc_default_timezone,会报错: { 2012 rufus-scheduler inte ...
- css 冷知识
*{margin: 0;padding: 0;} li{list-style-type:none; }ul{list-style: none;}img{border: none;}ul,input,s ...
- jmeter 使用白皮书
一.jmeter中的响应端言 断言就类似LoadRunner中的检查点.对上一个请求返回的信息,做字符串.数据包大小.HTML.XML.图片等做判断,确保返回的信息的准确性. 以下只讲解下响应断言步骤 ...
- bzoj 3238
后缀数组+单调栈的应用 首先我们研究一下这个表达式,可以发现前半部分与串的情况并没有关系,而只是跟串的长度有关,所以我们先把前半部分算出来: 于是我们只需计算出即可 那么可以发现,对于排名分别为i,j ...
- MNIST数字识别问题
摘自<Tensorflow:实战Google深度学习框架> import tensorflow as tf from tensorflow.examples.tutorials.mnist ...