利用   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>
 

最新文章

  1. linux启动SSH及开机自动启动
  2. tp中session用来做权限方法 (缓解mysql压力)
  3. IIS 服务没有及时响应启动或控制请求
  4. pgsql 9.4修改数据库只读
  5. 你好,C++(35)类是如何藏私房钱的?6.2.4 拷贝构造函数
  6. nodejs的npm安装模块时候报错:npm ERR! Error: CERT_NOT_YET_VALID的解决方法 - 包子博客 _ 关注互联网前端、开发、SEO、移动互联网应用技术
  7. 静态TLS和动态TLS
  8. string,char*,int 之间的转化
  9. JsRender实用入门教程
  10. Business Intelligence Tools We Recommend 1/4 – Metabase
  11. 微信小程序onLaunch异步,首页onLoad先执行?
  12. P2P的原理和常见的实现方式
  13. Maya cmds pymel 单位和轴向设置
  14. AICODER官方小程序和公众号上线了
  15. linq操作符:元素操作符
  16. 把AspDotNetCoreMvc程序运行在Docker上-part4:实现负载均衡
  17. Codeforces Round #540 (Div. 3)题解
  18. ios 中的tintColor
  19. hadoop+spark集群搭建入门
  20. Android事件处理下(按键、触摸屏和滚动球的一些实现细节)

热门文章

  1. Spring中@Async-异步处理
  2. Solidworks 2019 无法获得下列许可solidworks standard无效的(不一致的)使用许可号码(-8,544,0)
  3. xpath使用技巧
  4. CSS-格式化上下文(Formatting Context)
  5. leetcode 190. 颠倒二进制位(c++)
  6. 《图解设计模式》读书笔记4-2 STRATEGY模式
  7. 【OpenGL】---认识CubeTexture
  8. Songwriter CF1252-E(贪心)
  9. mooc-IDEA 应用快捷键自动创建测试类--010
  10. 统计Git