From 4bf8e47b371823df369d3498cb4f53de50f14d01 Mon Sep 17 00:00:00 2001 From: betavs Date: Wed, 8 Jan 2025 23:00:00 +0800 Subject: [PATCH] fix(ActionSheet): move initialization to observer for better visibility handling --- src/action-sheet/action-sheet.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/action-sheet/action-sheet.ts b/src/action-sheet/action-sheet.ts index c78d2c1dc..a8e0607f1 100644 --- a/src/action-sheet/action-sheet.ts +++ b/src/action-sheet/action-sheet.ts @@ -36,10 +36,13 @@ export default class ActionSheet extends SuperComponent { }, ]; - ready() { - this.memoInitialData(); - this.splitGridThemeActions(); - } + observers = { + visible(value: boolean) { + if (!value) return; + this.memoInitialData(); + this.splitGridThemeActions(); + }, + }; methods = { onSwiperChange(e: WechatMiniprogram.TouchEvent) { @@ -65,7 +68,6 @@ export default class ActionSheet extends SuperComponent { ...options, visible: true, }); - this.splitGridThemeActions(); this.autoClose = true; this._trigger('visible-change', { visible: true }); },