Skip to content

Commit 7174bda

Browse files
committed
refactor: 精简代码
1 parent 1c17f9c commit 7174bda

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/BootstrapBlazor/Components/Button/SlideButton.razor.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,9 @@ export function init(id) {
2323
EventHandler.on(list, 'click', '.slide-item', e => {
2424
list.classList.remove('show')
2525
})
26-
27-
const module = registerBootstrapBlazorModule('SlideButton', {
28-
handle: false,
29-
items: [],
30-
registerClosePopupHandler: function () {
31-
if (this.handle === false) {
32-
this.handle = true;
33-
34-
EventHandler.on(document, 'click', closePopup);
35-
}
36-
}
26+
registerBootstrapBlazorModule('SlideButton', id, () => {
27+
EventHandler.on(document, 'click', closePopup)
3728
});
38-
module.registerClosePopupHandler();
39-
module.items.push(id);
4029
}
4130

4231
export function update(id) {
@@ -57,10 +46,9 @@ export function dispose(id) {
5746
}
5847

5948
const { SlideButton } = window.BootstrapBlazor;
60-
SlideButton.items.pop(id)
61-
if (SlideButton.items.length === 0) {
49+
SlideButton.dispose(id, () => {
6250
EventHandler.off(document, 'click', closePopup)
63-
}
51+
});
6452
}
6553

6654
const reset = slide => {

0 commit comments

Comments
 (0)