1 安装指定版本的插插件
npm i vue-awesome-swiper@4.1.1 --save
npm i vue-awesome-swiper@4.1.1 --save
2.在main.js 中引用
import VueAwesomeSwiper from 'vue-awesome-swiper'
Vue.use(VueAwesomeSwiper)
3. 在使用的页面调用
<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>
<swiper-slide>Slide 10</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: 'Home',
title: 'Pagination',
components: {
Swiper,
SwiperSlide
},
data() {
return {
swiperOption: {
spaceBetween: 30,
pagination: {
el: '.swiper-pagination',
clickable: true
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
}
}
}
}
}
</script>
<style lang="scss" scoped>
.swiper {
height: 300px;
width: 100%;
border: 1px transparent solid;
.swiper-slide {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-weight: bold;
font-size: 14px;
background-color: rgb(98, 168, 200);
}
}
</style>
4. 具体的模板访问 vue-awesome-swiper | Homepage | Surmon's projects
注意 : 根据自己的ui图写样式就可以了