利用   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项目轮播图的实现的更多相关文章

  1. vue自定义轮播图组件 swiper

    1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...

  2. vue+mui轮播图

    mui的轮播图,如果图片是请求来的,直接在html中循环是不会动的. 需要请求完图片之后,在setTimeout方法里,使用slider()方法,这样才会动 而且mui的轮播图,有点坑的,需要重复最后 ...

  3. vue简易轮播图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. vue中轮播图的实现

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. vue实现轮播图

    /* Start  基本样式*/ * {   margin: 0;   padding: 0; } ul {   list-style-type: none; } body {   font-size ...

  6. vue编写轮播图组件

    <template>  <div id="slider">    <div class="window" @mouseover=& ...

  7. vue music-抓取歌单列表数据(渲染轮播图)

    下载安装新依赖 babel-runtime:对es6语法进行转译 fastclick:对移动端进行点击300毫秒延迟 ,,取消掉 babel-polyfill:API 先添加,在npm install ...

  8. vue轮播图

    vue开发中遇到这样一个需求实现导航栏和中间内容相结合实现页面滑动导航跟随改变的效果.看效果: 这里我用的是vue所带的插件:vue-awesome-swiper,传送门:https://www.np ...

  9. vue-awesome-swiper 轮播图使用

    最近在做vue 的轮播图的问题,项目中也遇到一些问题,查了 swiper 官网资料, 还有vue-awesome-swiper的文案,最后把怎么使用这个插件简单的说下,啥东西都需要自己实践下,还是老规 ...

随机推荐

  1. 台哥原创:java 数独源码

    2010年,当时正在做手机游戏的客户端开发工作. 每天加班之余,用了两三个晚上,开发了这个数独. 主要是生成数独数组的算法,有点难度.. ​ 如下图:点选数字栏里的数字后,界面上所有该数字会高亮显示. ...

  2. Android7.1后对于Toast类型窗口的限制

    在处理问题的时候,经常会遇到ANR,停止运行等问题,经过分析和验证,和如下的一行关键log有关 WindowManager: Adding more than one toast window for ...

  3. 测开之路七十七:shell之if、case、for、while

    选择语句(if语句) 大于:-gt判断目录是否存在:-d if [ 判断条件 ]; then statement1 Statement2elif [ 判断条件 ]; then statement1 S ...

  4. PHP点滴记录

    mysqli_fetch_object() //取得当前行,并作为对象返回 mysqli_fetch_row() //从结果集中取得一行,并作为枚举数组返回 mysqli_fetch_array() ...

  5. C#计算两个日期的相隔天数

    DateTime start = Convert.ToDateTime(dateStart.ToShortDateString()); DateTime end = Convert.ToDateTim ...

  6. phpstudy开启PHPSocket扩展(windows系统)

    PHP开启Socket扩展 一.windows系统(本地电脑) 1.打开phpstudy,设置——>配置文件——>打开php.ini(我安装的是PhpStudy v8.0,其他版本请自己找 ...

  7. jmeter:清除本地指定目录下的所有类型文件

    1,创建一个sampler 2,要在本地有一个目录的文件 3,直接上代码 String path = "C:\\临时文件\\test111" ;         File file ...

  8. 《JAVA设计模式》之装饰模式(Decorator)

    在阎宏博士的<JAVA与模式>一书中开头是这样描述装饰(Decorator)模式的: 装饰模式又名包装(Wrapper)模式.装饰模式以对客户端透明的方式扩展对象的功能,是继承关系的一个替 ...

  9. HashMap和布隆过滤器命中性能测试

    package datafilter; import com.google.common.base.Stopwatch; import com.google.common.hash.BloomFilt ...

  10. CentOS vim的使用

    安装vim工具 [root@bogon ~]# yum install -y vim-enhanced 卸载vim工具 [root@bogon ~]# yum remove -y vim* vim常用 ...