diff --git a/pages/home/index.vue b/pages/home/index.vue index c6fd564..a2f9875 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -45,6 +45,8 @@ autoplay circular style="height: 510rpx;" + :duration="500" + @animationfinish="bindSwiperInstance($event, 'banner')" > - - + + @@ -301,6 +305,8 @@ circular autoplay :interval="3000" + :duration="500" + @animationfinish="bindSwiperInstance($event, 'productSwiper')" > { + swiper && swiper.autoplayStart && swiper.autoplayStart() + }) + }, + // 页面隐藏时暂停轮播 + pageToHideHandle() { + // 暂停所有轮播组件的自动播放 + Object.values(this.swiperInstances).forEach(swiper => { + swiper && swiper.autoplayStop && swiper.autoplayStop() + }) + }, + // 绑定轮播组件实例 + bindSwiperInstance(e, key) { + this.swiperInstances[key] = e.detail + }, changeRecommendKeyword(e) { this.keywordIndex = e },