vue-awesome-swiper实现内容翻页
时间: 2023-11-28 22:44:21 浏览: 86
以下是使用vue-awesome-swiper实现内容翻页的示例:
1. 首先安装vue-awesome-swiper:
```shell
npm install vue-awesome-swiper --save-dev
```
2. 在Vue组件中引入vue-awesome-swiper:
```javascript
<template>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
</div>
<div class="swiper-pagination"></div>
</div>
</template>
<script>
import 'swiper/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
components: {
swiper,
swiperSlide
},
data () {
return {
swiperOption: {
pagination: '.swiper-pagination',
paginationClickable: true
}
}
}
}
</script>
<style>
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
display: flex;
justify-content: center;
align-items: center;
}
</style>
```
3. 在Vue组件中使用vue-awesome-swiper:
```javascript
<template>
<swiper :options="swiperOption">
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
</swiper>
</template>
<script>
import 'swiper/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
components: {
swiper,
swiperSlide
},
data () {
return {
swiperOption: {
pagination: '.swiper-pagination',
paginationClickable: true
}
}
}
}
</script>
<style>
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
display: flex;
justify-content: center;
align-items: center;
}
</style>
```
阅读全文