<template> <div class="swiper-size"> <swiper :options="swiperOption"> <swiper-slide v-for="(slide, index) in bannerImg" :key="index"> <img class="swiperimg" :src="slide" alt="" /> </swiper-slide> <div class="swiper-pagination" slot="pagination"></div> </swiper> </div> </template> <script> export default { data() { return { swiperOption:{ }, bannerImg: [ require("../../../assets/slideShow/j1.jpg"), require("../../../assets/slideShow/j2.jpg"), require("../../../assets/slideShow/j3.jpg"), require("../../../assets/slideShow/j4.jpg"), ], }; }, } </script>在这段代码下能不能做出只显示一张图片的轮播图
时间: 2024-03-23 22:42:34 浏览: 64
vue-awesome-swiper滑块插件使用方法详解
可以,只需要在 `swiperOption` 中设置 `loop` 和 `autoplay` 属性为 `false`,并且将 `slidesPerView` 属性设置为 `1`,即可实现只显示一张图片的轮播图,具体代码如下:
```
<template>
<div class="swiper-size">
<swiper :options="swiperOption">
<swiper-slide v-for="(slide, index) in bannerImg" :key="index">
<img class="swiperimg" :src="slide" alt="" />
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>
<script>
export default {
data() {
return {
swiperOption: {
loop: false, // 不循环
autoplay: false, // 不自动播放
slidesPerView: 1 // 每次只显示一张图片
},
bannerImg: [
require("../../../assets/slideShow/j1.jpg")
],
};
},
}
</script>
```
阅读全文