|
1
|
<template>
|
|
2
3
4
5
6
7
8
9
|
<BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
title="Modal Title"
:helpMessage="['提示1', '提示2']"
@visible-change="handleShow"
>
|
|
10
|
<template #insertFooter>
|
Vben
authored
|
11
|
<a-button type="primary" danger @click="setLines" :disabled="loading">点我更新内容</a-button>
|
|
12
|
</template>
|
|
13
|
<template v-if="loading">
|
vben
authored
|
14
|
<div class="empty-tips">加载中,稍等3秒……</div>
|
|
15
16
17
18
19
20
|
</template>
<template v-if="!loading">
<ul>
<li v-for="index in lines" :key="index">加载完成{{ index }}!</li>
</ul>
</template>
|
|
21
22
23
|
</BasicModal>
</template>
<script lang="ts">
|
|
24
|
import { defineComponent, ref, watch } from 'vue';
|
|
25
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
26
27
|
export default defineComponent({
components: { BasicModal },
|
|
28
29
30
31
|
setup() {
const loading = ref(true);
const lines = ref(10);
const [register, { setModalProps, redoModalHeight }] = useModalInner();
|
|
32
33
34
35
36
|
watch(
() => lines.value,
() => {
redoModalHeight();
|
vben
authored
|
37
|
},
|
|
38
39
|
);
|
|
40
41
42
|
function handleShow(visible: boolean) {
if (visible) {
loading.value = true;
|
|
43
|
setModalProps({ loading: true, confirmLoading: true });
|
|
44
|
setTimeout(() => {
|
|
45
|
lines.value = Math.round(Math.random() * 30 + 5);
|
|
46
|
loading.value = false;
|
|
47
|
setModalProps({ loading: false, confirmLoading: false });
|
|
48
49
50
|
}, 3000);
}
}
|
|
51
52
53
54
55
|
function setLines() {
lines.value = Math.round(Math.random() * 20 + 10);
}
return { register, loading, handleShow, lines, setLines };
|
|
56
|
},
|
|
57
58
|
});
</script>
|
|
59
60
61
62
63
64
65
|
<style scoped>
.empty-tips {
height: 100px;
line-height: 100px;
text-align: center;
}
</style>
|