1.添加判断,如果轮播图为1张时,不滚动

This commit is contained in:
2026-04-01 11:02:05 +08:00
parent cef8924ed3
commit 81c5070e4d
+2 -2
View File
@@ -403,7 +403,7 @@
},
// 初始化 Swiper
initSwiper() {
if (this.swiperList.length === 0) return;
if (this.swiperList.length <= 1) return;
this.swiperInstance = new Swiper('.swiper-container', {
loop: true,
grabCursor: true,
@@ -421,7 +421,7 @@
},
// Swiper 滑动事件处理
onSwiperSlideChange() {
if (!this.swiperInstance || this.swiperList.length === 0) return
if (!this.swiperInstance || this.swiperList.length <= 1) return;
// 获取当前索引
const realIndex = this.swiperInstance.activeIndex;
this.currentSwiperIndex = realIndex;