Skip to content

Commit aaf5d4f

Browse files
authored
fix(modal): [modal] modify bug (#2106)
1 parent e20f70a commit aaf5d4f

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

examples/sites/demos/pc/app/modal/message-closable-composition-api.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ function showModal() {
1313
status: 'info',
1414
messageClosable: true,
1515
events: {
16+
hide: () => {
17+
Notify({
18+
type: 'info',
19+
title: '触发hide回调事件',
20+
position: 'top-right'
21+
})
22+
},
1623
close: () => {
1724
Notify({
1825
type: 'info',

examples/sites/demos/pc/app/modal/message-closable.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66

77
<script>
8-
import { Button, Modal } from '@opentiny/vue'
8+
import { Button, Modal, Notify } from '@opentiny/vue'
99
1010
export default {
1111
components: {
@@ -18,6 +18,13 @@ export default {
1818
status: 'info',
1919
messageClosable: true,
2020
events: {
21+
hide: () => {
22+
Notify({
23+
type: 'info',
24+
title: '触发hide回调事件',
25+
position: 'top-right'
26+
})
27+
},
2128
close: () => {
2229
Notify({
2330
type: 'info',

packages/renderless/src/modal/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,13 @@ export const close =
370370
state.contentVisible = false
371371
setTimeout(() => {
372372
state.visible = false
373-
374373
let params = { type, $modal: parent }
375-
if (events.close) {
376-
events.close.call(parent, params)
374+
emit('close', params)
375+
if (events.hide) {
376+
events.hide.call(parent, params)
377377
} else {
378378
emit('update:modelValue', false)
379-
emit('close', params)
379+
emit('hide', params)
380380
}
381381
}, 200)
382382
}

packages/vue/src/modal/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ export function Modal(options) {
3131
let events = options.events || {}
3232
let $modal
3333
options.events = Object.assign({}, events, {
34+
hide(params) {
35+
events.hide && events.hide.call(this, params)
36+
if ($modal.beforeUnmouted) {
37+
$modal.beforeUnmouted()
38+
}
39+
resolve(params.type)
40+
},
3441
confirm(params) {
3542
events.confirm && events.confirm.call(this, params)
3643
},
3744
show(params) {
3845
events.show && events.show.call(this, params)
39-
},
40-
close(params) {
41-
events.close && events.close.call(this, params)
42-
if ($modal.beforeUnmouted) {
43-
$modal.beforeUnmouted()
44-
}
45-
resolve(params.type)
4646
}
4747
})
4848

0 commit comments

Comments
 (0)