diff --git a/src/action-sheet/action-sheet.ts b/src/action-sheet/action-sheet.ts index c78d2c1dc..ad954c558 100644 --- a/src/action-sheet/action-sheet.ts +++ b/src/action-sheet/action-sheet.ts @@ -36,19 +36,27 @@ export default class ActionSheet extends SuperComponent { }, ]; + observers = { + items() { + this.init(); + }, + }; + ready() { - this.memoInitialData(); - this.splitGridThemeActions(); + this.init(); } methods = { - onSwiperChange(e: WechatMiniprogram.TouchEvent) { - const { - detail: { current }, - } = e; - this.setData({ - currentSwiperIndex: current, - }); + init() { + this.memoInitialData(); + this.splitGridThemeActions(); + }, + + memoInitialData() { + this.initialData = { + ...this.properties, + ...this.data, + }; }, splitGridThemeActions() { @@ -70,13 +78,6 @@ export default class ActionSheet extends SuperComponent { this._trigger('visible-change', { visible: true }); }, - memoInitialData() { - this.initialData = { - ...this.properties, - ...this.data, - }; - }, - /** 指令调用隐藏 */ close() { this.triggerEvent('close', { trigger: 'command' }); @@ -95,6 +96,13 @@ export default class ActionSheet extends SuperComponent { } }, + onSwiperChange(e: WechatMiniprogram.TouchEvent) { + const { current } = e.detail; + this.setData({ + currentSwiperIndex: current, + }); + }, + onSelect(event: WechatMiniprogram.TouchEvent) { const { currentSwiperIndex, items, gridThemeItems, count, theme } = this.data; const { index } = event.currentTarget.dataset;