|
1
|
<template>
|
vben
authored
|
2
|
<PageWrapper title="modal组件使用示例">
|
|
3
4
|
<Alert
message="使用 useModal 进行弹窗操作,默认可以拖动,可以通过 draggable
|
|
5
|
参数进行控制是否可以拖动/全屏,并演示了在Modal内动态加载内容并自动调整高度"
|
|
6
7
|
show-icon
/>
|
vben
authored
|
8
|
<a-button type="primary" class="my-4" @click="openModalLoading">
|
|
9
|
打开弹窗,加载动态数据并自动调整高度(默认可以拖动/全屏)
|
vben
authored
|
10
|
</a-button>
|
|
11
|
|
vben
authored
|
12
|
<Alert message="内外同时同时显示隐藏" show-icon />
|
vben
authored
|
13
|
<a-button type="primary" class="my-4" @click="openModal2"> 打开弹窗 </a-button>
|
vben
authored
|
14
|
<Alert message="自适应高度" show-icon />
|
vben
authored
|
15
|
<a-button type="primary" class="my-4" @click="openModal3"> 打开弹窗 </a-button>
|
|
16
|
|
Vben
authored
|
17
|
<Alert message="内外数据交互" show-icon />
|
vben
authored
|
18
|
<a-button type="primary" class="my-4" @click="send"> 打开弹窗并传递数据 </a-button>
|
|
19
|
|
|
20
|
<Modal1 @register="register1" :minHeight="100" />
|
|
21
22
23
|
<Modal2 @register="register2" />
<Modal3 @register="register3" />
<Modal4 @register="register4" />
|
vben
authored
|
24
|
</PageWrapper>
|
|
25
26
27
28
29
30
31
32
33
|
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { Alert } from 'ant-design-vue';
import { useModal } from '/@/components/Modal';
import Modal1 from './Modal1.vue';
import Modal2 from './Modal2.vue';
import Modal3 from './Modal3.vue';
import Modal4 from './Modal4.vue';
|
vben
authored
|
34
35
|
import { PageWrapper } from '/@/components/Page';
|
|
36
|
export default defineComponent({
|
vben
authored
|
37
|
components: { Alert, Modal1, Modal2, Modal3, Modal4, PageWrapper },
|
|
38
|
setup() {
|
|
39
|
const [register1, { openModal: openModal1 }] = useModal();
|
|
40
41
|
const [register2, { openModal: openModal2 }] = useModal();
const [register3, { openModal: openModal3 }] = useModal();
|
vben
authored
|
42
|
const [register4, { openModal: openModal4 }] = useModal();
|
|
43
|
function send() {
|
vben
authored
|
44
45
46
47
|
openModal4(true, {
data: 'content',
info: 'Info',
});
|
|
48
49
|
}
function openModalLoading() {
|
|
50
51
52
53
54
|
openModal1(true);
// setModalProps({ loading: true });
// setTimeout(() => {
// setModalProps({ loading: false });
// }, 2000);
|
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
}
return {
register1,
openModal1,
register2,
openModal2,
register3,
openModal3,
register4,
openModal4,
send,
openModalLoading,
};
},
});
</script>
|