vue-awesome-swiper当前轮播下标
时间: 2023-11-16 18:06:43 浏览: 155
要获取vue-awesome-swiper当前轮播下标,可以在swiper的slideChangeTransitionEnd事件中使用this.activeIndex属性来获取当前激活的slide的下标。具体实现可以参考以下代码:
```
<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 VueAwesomeSwiper from "vue-awesome-swiper";
import "swiper/css/swiper.css";
export default {
data() {
return {
swiperOptions: {
direction: "horizontal",
loop: true,
pagination: {
el: ".swiper-pagination",
clickable: true
}
},
activeIndex: 0
};
},
components: {
VueAwesomeSwiper
},
methods: {},
mounted() {},
created() {},
watch: {},
computed: {},
swiper: null
};
</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>
```
在上述代码中,我们在data中声明了activeIndex属性,并在swiperOptions中的slideChangeTransitionEnd事件中将当前激活的slide的下标赋值给activeIndex属性。这样我们就可以在组件中使用activeIndex属性来获取当前轮播下标了。
阅读全文