Skip to content

Commit

Permalink
fix(action-sheet): refactor initialization and observer for items update
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs committed Jan 14, 2025
1 parent 024269b commit bc97977
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/action-sheet/action-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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' });
Expand All @@ -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;
Expand Down

0 comments on commit bc97977

Please sign in to comment.