vue项目轮播图的实现
利用 Vue-Awesome-Swiper插件来做轮播效果,github地址:https://github.com/surmon-china/vue-awesome-swiper
安装
npm install vue-awesome-swiper --save
页面中引用
import 'swiper/dist/css/swiper.css' import { swiper, swiperSlide } from 'vue-awesome-swiper'
代码如下:
<template>
<div class="wrapper">
<swiper :options="swiperOption" ref="mySwiper" @someSwiperEvent="callback">
<!-- slides -->
<swiper-slide v-for="item of swiperList" :key="item.id">
<img class="swiper-img" :src="item.url" alt="">
</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>
</div>
</template> <script>
export default {
name: 'HomeSwiper',
data () {
return {
swiperOption: {
pagination: '.swiper-pagination',
loop: true //循环轮播
},
swiperList: [{
id: '001',
url: 'https://imgs.qunarzz.com/vs_ceph_vs_tts/fb5fbf5c-4f85-482b-91d6-4ce17a42618d.jpg_r_390x260x90_aae85edf.jpg'
}, {
id: '0002',
url: 'https://imgs.qunarzz.com/sight/p0/1411/34/6aec007588037c2d9ef339d81aeba256.water.jpg_256x160_ec997312.jpg'
}]
}
}
}
</script> <style scoped>
.wrapper >>> .swiper-pagination-bullet-active {
background: red;
}
.swiper-img {
width: 100%
}
.wrapper {
overflow: hidden;
width: 100%;
height: 0;
padding-bottom: 31.25% /*相对于宽高比自动撑开 */
/* width:100%;
height: 31.25vw; 除了上面那种方法,也可以这么写,意思是宽高比例*/
}
</style>
vue项目轮播图的实现的更多相关文章
- vue自定义轮播图组件 swiper
1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...
- vue+mui轮播图
mui的轮播图,如果图片是请求来的,直接在html中循环是不会动的. 需要请求完图片之后,在setTimeout方法里,使用slider()方法,这样才会动 而且mui的轮播图,有点坑的,需要重复最后 ...
- vue简易轮播图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- vue中轮播图的实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- vue实现轮播图
/* Start 基本样式*/ * { margin: 0; padding: 0; } ul { list-style-type: none; } body { font-size ...
- vue编写轮播图组件
<template> <div id="slider"> <div class="window" @mouseover=& ...
- vue music-抓取歌单列表数据(渲染轮播图)
下载安装新依赖 babel-runtime:对es6语法进行转译 fastclick:对移动端进行点击300毫秒延迟 ,,取消掉 babel-polyfill:API 先添加,在npm install ...
- vue轮播图
vue开发中遇到这样一个需求实现导航栏和中间内容相结合实现页面滑动导航跟随改变的效果.看效果: 这里我用的是vue所带的插件:vue-awesome-swiper,传送门:https://www.np ...
- vue-awesome-swiper 轮播图使用
最近在做vue 的轮播图的问题,项目中也遇到一些问题,查了 swiper 官网资料, 还有vue-awesome-swiper的文案,最后把怎么使用这个插件简单的说下,啥东西都需要自己实践下,还是老规 ...
随机推荐
- HDU 6024 Building Shops (简单dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6024 题意:有n个room在一条直线上,需要这这些room里面建造商店,如果第i个room建造,则要总 ...
- webService接口的py文件打包成exe
(一)webService接口的py文件打包成exe,在python3.5版本.pyInstaller3.2版本.pywin32-219.win-amd64-py3.5版本打包时报错,原因可能是pyi ...
- day10—jQuery初步实践,关于菜单
转行学开发,代码100天——2018-03-26 今天是本人写开发记录方面博客的第10天了,不知不觉已经涉及到jQuery框架的学习了. 第一次熬夜写前端代码还是两年前,不过中途放弃了,学的东西也日渐 ...
- tools-eclipse-003-下载安装优化
一.下载 1.1.jdk安装 下载:http://www.oracle.com/technetwork/java/javase/downloads/index.html 安装:不需要安装jre,默认会 ...
- 浮点数float累加误差解决方式总结
首先是float累加产生误差的原因,该部分转自:http://blog.csdn.net/zhrh0096/article/details/38589067 1. 浮点数IEEE 754表示方法 要 ...
- poi3617Best Cow Line ——贪心法
给定长度为N(1≤N≤2000)的字符串S,要构造一个长度为N的字符串T.期初,T是一个空串,随后反复进行下列任意操作. ·从S的头部删除一个字符,加到T的尾部 ·从S的尾部删除一个字符,加到T的尾部 ...
- Interface-接口的实现与注意事项
package cn.learn.Interface; public interface MyInterfaceA { public abstract void methodA(); public a ...
- Android 中三种启用线程的方法
在多线程编程这块,我们经常要使用Handler(处理),Thread(线程)和Runnable这三个类,那么他们之间的关系你是否弄清楚了呢? 首先说明Android的CPU分配的最小单元是线程,Han ...
- 任务调度(02)Spring Schedule
任务调度(02)Spring Schedule [toc] Spring 3.0 提供两种任务调度方式:一是定时任务调度:二是异步任务调度.这两种任务调度方式都是基于 JUC 实现的,是一种非常轻量级 ...
- mysql练习题目试水50题,附建库sql代码
如果你没试过水的话,那一题一题地每一题都敲一遍吧.不管它们对你看来有多么简单. 建库代码 部分题目答案在末尾,可用ctrl f 搜索题号. 作业练习——学生-选课 表结构 学生表: Student ...