vue-awesome-swiper实现轮播图
2024-10-01 08:06:24
1.首先通过npm安装vue-awesome-swiper,我在项目中用的是2.6.7版本
npm install vue-awesome-swiper@2.6.7 –save
2. 在main.js中引入
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)
3.实现轮播图
- <template>
- <div class="wrapper">
- <swiper :options="swiperOption" v-if="showSwiper" ref="mySwiper" >
- <!-- slides -->
- <swiper-slide v-for="item of list" :key="item.id">
- <img class="swiper-img" :src="item.imgUrl"/>
- </swiper-slide>
- <div class="swiper-pagination" slot="pagination"></div>
- </swiper>
- </div>
- </template>
- <script>
- export default {
- name:"HomeSwiper",
- props:{
- list:Array
- },
- data (){
- return{
- swiperOption:{
- pagination:".swiper-pagination",
- autoplay: 2000,
- loop:true,
- paginationClickable: true,
- observer:true,
- observeParents:true
- }
- }
- } ,
- computed: {
- showSwiper () {
- return this.list.length
- }
- }
- }
- </script>
- <style lang="stylus" scoped>
- .wrapper >>> .swiper-pagination-bullet-active
- background:#fff
- .wrapper
- overflow:hidden
- width:100%
- height 0
- padding-bottom:31.25%
- background:#eee
- .swiper-img
- width:100%
- </style>
最新文章
- norflash驱动编写笔记
- python 多线程和多核
- apktool反编译apk文件
- MVC @functions
- css 字数超过一行显示省略号
- 自己写CPU第九阶段(3)——加载存储指令说明2(swl、swr)
- 验证mySqli扩展是否
- 对Java的初识
- struts2(四)之输入校验
- c#关键字及ref和out
- 关于docker jenkins启动时失败的问题处理
- 从AST编译解析谈到写babel插件
- 尚硅谷springboot学习30-docker安装mysql示例
- 《算法》第四章部分程序 part 11
- SpringMVC框架04——RESTful入门
- 20155211 2016-2017-2 《Java程序设计》第九周学习总结
- mongodb 日志清理
- JS设计模式——3.封装与信息隐藏
- ogr2ogr使用
- spring和hibernate整合,事务管理