Skip to content

Commit 50c49c0

Browse files
committed
feat: add close
1 parent 8d88817 commit 50c49c0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/common/Message/index.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</transition>
1010
</template>
1111
<script lang="ts" setup>
12-
import { ref, onMounted, onUnmounted } from "vue";
12+
import { ref, onMounted, onBeforeUnmount, defineProps } from "vue";
1313
import type { MessageType } from "./type";
1414
// 是否可见
1515
const visible = ref(false);
@@ -26,10 +26,20 @@ const keyDown = () => {};
2626
// 关闭弹窗
2727
const close = () => {};
2828
29+
const props = defineProps({
30+
content: String, // 文字类型
31+
isHTML: Boolean, // 是否是html
32+
duration: Number, // 显示时长
33+
onClose: Function, // 关闭时的调用
34+
});
35+
2936
onMounted(() => {
3037
console.log("message box onMounted");
3138
});
32-
onUnmounted(() => {
39+
onBeforeUnmount(() => {
40+
if (typeof props.onClose === "function") {
41+
props.onClose();
42+
}
3343
console.log("message box onUnmounted");
3444
});
3545
</script>

0 commit comments

Comments
 (0)