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的文案,最后把怎么使用这个插件简单的说下,啥东西都需要自己实践下,还是老规 ...
随机推荐
- MongoDB数据迁移
将集合user从192.168.1.12:27017导入到192.168.1.120:27017 数据的导出:mongoexport 数据的导入:mongoimport 导出集合user的过程: [r ...
- ruby类对象和对象
class Box def initialize(w,h) @width,@height=w,h end def getArea puts "class of self #{self.cla ...
- http代理工具delphi源码
http://www.caihongnet.com/content/xingyexinwen/2013/0721/730.html http代理工具delphi源码 以下代码在 DELPHI7+IND ...
- quick bi dashboard 控件样式控制。
控件样式控制 1 想要的效果图 2 查询样式里面进行设置
- 在reshard过程中,将会询问reshard多少slots:
How many slots do you want to move (from 1 to 16384)?,取值范围为1~16384,其中16384为redis cluster的拥有的slots总数, ...
- JSP 定义行列数表单创建表格
1.添加行数 .列数提交表单 <!doctype html> <html> <head> <title>setTable-发送表单</title& ...
- pygame应用——生产者消费者模型
因为操作系统的一个生产者-消费者拓展作业,以一个飞机大战的模型修改来的 import pygame import time from pygame.locals import * bulletsNum ...
- workflow-core 简介
最近想做一个OA相关的网站开发,一直都听说有workflow的东西,之前也断断续续学习过 Workflow Foundation 4.0,还是没有搞明白到底能够用它做什么 但还是觉得workflow在 ...
- Expected one result (or null) to be returned by selectOne() 数据库结果集和java实例
mybatis会根据查询的结果集初始化java实例. 如果是复杂类型,我们一般都会在mapper中做好映射. 1.所以如果查询到的是多个结果,那么对应的java类型也必须的集合类型.(result 为 ...
- MySQL的数据类型:文本、数字、日期/时间
在MySQL中,有三种主要的类型:文本.数字和日期/时间类型. 文本类型(text):数据类型 描述 CHAR(size) 保存固定长度 ...