vue中写轮播图的福音-vue-awesome-swiper-里面全都有
vue中使用vue-awesome-swiper的方法
带分页器、带左右按钮、垂直滑动、水平滑动、多图滑动、3d效果、缩略图控制
等等等,需要的基本都有
安装swiper
npm install vue-awesome-swiper --save
配置swiper(main.js)
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)
然后在要使用的swiper的组件中引入
import { swiper,swiperSlide} from 'vue-awesome-swiper'
开始写轮播图 可以看官网demo案例
<template>
<swiper class="swiper" :options="swiperOption">
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
<swiper-slide>Slide 4</swiper-slide>
<swiper-slide>Slide 5</swiper-slide>
<swiper-slide>Slide 6</swiper-slide>
<swiper-slide>Slide 7</swiper-slide>
<swiper-slide>Slide 8</swiper-slide>
<swiper-slide>Slide 9</swiper-slide>
<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>
</template>
<script>
import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
import 'swiper/css/swiper.css'
export default {
name: 'swiper-example-loop-group',
title: 'Loop mode with multiple slides per group',
components: {
Swiper,
SwiperSlide
},
data() {
return {
swiperOption: {
slidesPerView: 3,
spaceBetween: 30,
slidesPerGroup: 3,
loop: true,
loopFillGroupWithBlank: true,
pagination: {
el: '.swiper-pagination',
clickable: true
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
}
}
}
}
}
</script>
<style lang="scss" scoped>
@import './base.scss';
</style>
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634472.html