diff --git a/pages/home/index.vue b/pages/home/index.vue index a2f9875..1b599d2 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -189,7 +189,7 @@ - + @@ -459,7 +459,13 @@ export default { shareData: {}, currentIndex: 0, // 轮播组件实例 - swiperInstances: {} + swiperInstances: { + productSwiper: true, + homestay: true, + banner: true, + festival: true, + newZone: true, + } } }, onLoad() { @@ -487,6 +493,9 @@ export default { } }) }, + onShow() { + this.pageToShowHandle() + }, onHide() { this.pageToHideHandle() }, @@ -511,20 +520,27 @@ export default { // 页面显示时恢复轮播 pageToShowHandle() { // 恢复所有轮播组件的自动播放 - Object.values(this.swiperInstances).forEach(swiper => { - swiper && swiper.autoplayStart && swiper.autoplayStart() - }) + this.swiperInstances = { + productSwiper: true, + homestay: true, + banner: true, + festival: true, + newZone: true, + } }, // 页面隐藏时暂停轮播 pageToHideHandle() { - // 暂停所有轮播组件的自动播放 - Object.values(this.swiperInstances).forEach(swiper => { - swiper && swiper.autoplayStop && swiper.autoplayStop() - }) + this.swiperInstances = { + productSwiper: false, + homestay: false, + banner: false, + festival: false, + newZone: false, + } }, // 绑定轮播组件实例 bindSwiperInstance(e, key) { - this.swiperInstances[key] = e.detail + // this.swiperInstances[key] = e.detail }, changeRecommendKeyword(e) { this.keywordIndex = e