vue-awesome-swiper轮播的使用
一、安装vue-awesome-swiper
npm install vue-awesome-swiper --save
二、引入插件
main.js里面分别引入(记得有些电脑要引入样式)
import vueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(vueAwesomeSwiper)
三、使用
<template>
<div class="content mt40">
<div class="banner">
<swiper :options="swiperOption" ref="mySwiper">
<!-- 这部分放你要渲染的那些内容 -->
<swiper-slide>
<img src="../../assets/images/img_1.jpg" alt=""/>
<div class="text-box">
<h2>还可以降低首付款健身房11111</h2>
<p>刘德华11 / 文</p>
</div>
</swiper-slide>
<swiper-slide>
<img src="../../assets/images/img_2.jpg" alt=""/>
<div class="text-box">
<h2>还可以降低首付款健身房2222</h2>
<p>刘德华22 / 文</p>
</div>
</swiper-slide>
<!-- 这是轮播的小圆点 -->
<div class="swiper-pagination banner-pagination" slot="pagination"></div>
</swiper>
</div>
</div>
</template>
<script>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default{
components: {
swiper,
swiperSlide
},
data(){
return{
swiperOption:{
//是一个组件自有属性,如果notNextTick设置为true,组件则不会通过NextTick来实例化swiper,
也就意味着你可以在第一时间获取到swiper对象,假如你需要刚加载遍使用获取swiper对象来做什么事,
那么这个属性一定要是true
//notNextTick: true,
autoplay: {
delay: 3000,
disableOnInteraction: false
},
speed:400,
autoHeight: true,
loop : true,
pagination: {
el: '.banner-pagination',
clickable: true
}
}
}
},
computed: { },
mounted(){ },
methods:{ }
}
</script>
<style>
body{
background:#f2f4f5;
}
.mt40{
margin-top:0.6rem;
}
.banner{width:6.4rem;position: relative;overflow: hidden; z-index: 1}
.swiper-container,.swiper-wrapper{
width:100%;
height: 100%;
}
.banner .swiper-slide{width:100%;
height:100%;}
.banner .swiper-slide img{max-width:100%;width:100%; display:block;}
.banner .swiper-slide .text-box{width:6.4rem; padding:0 0.3rem;height:1.24rem; position:absolute; left:0;
bottom:0; color:#fff; background:rgba(0,0,0,0.5);}
.text-box h2{ font-size:0.3rem; font-weight:normal; margin-top:0.22rem; line-height:100%; margin-bottom:0.22rem;
overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
.text-box p{ line-height:100%;} .banner-pagination{position:absolute; right:0.2rem;bottom:0.2rem;text-align: right;padding-right:0.3rem;}
.banner-pagination .swiper-pagination-bullet{width:0.2rem;height:0.2rem; background:#ffffff; }
.banner-pagination .swiper-pagination-bullet-active{ width:0.2rem;height:0.2rem;background:#5477b2;}
</style>
就是这么简单
vue-awesome-swiper轮播的使用的更多相关文章
- vue中引用swiper轮播插件
有时候我们需要在vue中使用轮播组件,如果是在vue组件中引入第三方组件的话,最好通过npm安装,从而进行统一安装包管理. 申明:本文所使用的是vue.2x版本. 通过npm安装插件: npm ins ...
- swiper轮播问题之一:轮播图内容为动态数据生成时轮播图无法自动轮播
本人在用H5做移动端项目中使用Swiper遇到的两个问题,因此加深了对Swiper的掌握,分享出来对刚开始接触Swiper的童鞋们或多或少会有帮助. 首先,new Swiper的初始化最 ...
- vue-awesome-swipe 基于vue使用的轮播组件 使用(改)
npm install vue-awesome-swiper --save //基于vue使用的轮播组件 <template> <swiper :options="swi ...
- 视频swiper轮播
关于本次文章的内容,实际上是咪咕阅读详情页中的一个前端需求要做的效果,不过比起原需求,此次案例已经被删减掉许多部分了.音频部分舍弃,调用客户端接口舍弃,并做一些整理.最后留下的是这个精简版的案例.方便 ...
- 使用Swiper轮播插件引起的探索
提到Swiper轮播插件,小伙伴们应该不会感到陌生.以前我主要在移动端上使用,PC端使用较少. 注:这里需要注意的是,在PC端和移动端使用Swiper是不同的 官方给的版本有三个,分别是Swiper2 ...
- swiper轮播在ie浏览器上遇到的显示问题探索
前言: 最近项目有一个需求,想要下图效果,鼠标指向头像图片,图片会放大同时上面的轮播会跟着切换: 鼠标移开头像图片,图片变回原来的大小 注:下图是我根据上面需求已经实现的效果,所以截图方便说明 思考: ...
- swiper轮播图(逆向自动切换类似于无限循环)
swiper插件轮播图,默认的轮播循序是会从右向左,第一张,第二张,第三张,然后肉眼可见是的从第三张从左到右倒回第一张,这样就会有些视觉体验不高, ,不过还是能够用swiper本身的特性更改成无限循环 ...
- Swiper轮播图
今天咱们来说一下.Swiper轮播图. 超级简单的: 翠花,上代码: <!DOCTYPE html> <html lang="en"> < ...
- 微信小程序_(组件)swiper轮播图
微信小程序swiper轮播图组件官方文档 传送门 Learn: swiper组件 一.swiper组件 indicator-dots:是否显示面板指示点[默认值false] autoplay:是否自动 ...
- Swiper轮播隐藏再显示后不动
公告用Swiper轮播方式,在某些不需要显示公告的页面进行隐藏,在需要展示公告的页面进行显示时候,公告不能正常轮播,在条件里加入重新设置轮播方法等网上的一些方法仍然不行,最后解决方法: this.my ...
随机推荐
- Windows上传代码到github操作指导
操作环境 Windows7(32bit) 前提条件 1.完成msysgit工具安装.下载路径:官网或百度网盘路径Git-2.15.0-32-bit.exe.安装方法为一路Next按照默认选项执行就可以 ...
- npm run dev 报错:missing script:dev
一.问题: 今天在运行vue项目时,在mac终端输入npm run dev,结果报错: 翻译是: npm错误:缺少script:dev npm错误:完整路径见:users/mymac/ .npm/_l ...
- Android 性能优化 SparseArray【转载】
原文地址:Android学习笔记之性能优化SparseArray 学习内容: 1.Android中SparseArray的使用.. 昨天研究完横向二级菜单,发现其中使用了SparseArray去替 ...
- javascript原型链中 this 的指向
为了弄清楚Javascript原型链中的this指向问题,我写了个代码来测试: var d = { d: 40 }; var a = { x: 10, calculate: function (z) ...
- Ubuntu系统下手动释放内存
有时候,像mongo这种,对内存只吃不吐的,我们要手动释放一下. drop_caches的详细文档如下:Writing to this will cause the kernel to drop cl ...
- el-js中循环遍历el的集合
遇到问题的代码: var score=0; for(var i=0;i<${fn:length(tMovie.tComments) };i++){ score=${tMovie.tComment ...
- sql 允许远程登录
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; flush privileges ...
- 【Nodejs】ExpressのRequestとResponseの内容
Request 对象 - request 对象表示 HTTP 请求,包含了请求查询字符串,参数,内容,HTTP 头部等属性.常见属性有: req.app:当callback为外部文件时,用req.ap ...
- redis.clients.jedis.exceptions.JedisException: Can connect to sentinel, but seems to be not monitored.
在使用Redis的哨兵Sentinel配置时,报错如下: redis.clients.jedis.exceptions.JedisException: Can connect to sentinel, ...
- data属性(The Data Attribute)
HTML片段 <div id="myDiv" data-custom-attr="My Value"> 巴拉巴拉,lady 嘎嘎 </div& ...