vue-vben-admin/src/views/demo/comp/modal/index.vue

74 lines
2.5 KiB
Vue
Raw Normal View History

2020-09-28 20:19:10 +08:00
<template>
<PageWrapper title="modal组件使用示例">
2020-09-28 20:19:10 +08:00
<Alert
message="使用 useModal 进行弹窗操作默认可以拖动可以通过 draggable
参数进行控制是否可以拖动/全屏并演示了在Modal内动态加载内容并自动调整高度"
2020-09-28 20:19:10 +08:00
show-icon
/>
2021-01-28 23:28:50 +08:00
<a-button type="primary" class="my-4" @click="openModalLoading">
打开弹窗,加载动态数据并自动调整高度(默认可以拖动/全屏)
2021-01-28 23:28:50 +08:00
</a-button>
2020-09-28 20:19:10 +08:00
2020-10-31 00:41:33 +08:00
<Alert message="内外同时同时显示隐藏" show-icon />
2021-01-28 23:28:50 +08:00
<a-button type="primary" class="my-4" @click="openModal2"> 打开弹窗 </a-button>
2020-10-31 00:41:33 +08:00
<Alert message="自适应高度" show-icon />
2021-01-28 23:28:50 +08:00
<a-button type="primary" class="my-4" @click="openModal3"> 打开弹窗 </a-button>
2020-09-28 20:19:10 +08:00
<Alert
message="内外数据交互,外部通过 transferModalData 发送,内部通过 receiveDrawerDataRef 接收。该数据具有响应式"
show-icon
/>
2021-01-28 23:28:50 +08:00
<a-button type="primary" class="my-4" @click="send"> 打开弹窗并传递数据 </a-button>
2020-09-28 20:19:10 +08:00
<Modal1 @register="register1" :minHeight="100" />
2020-09-28 20:19:10 +08:00
<Modal2 @register="register2" />
<Modal3 @register="register3" />
<Modal4 @register="register4" />
</PageWrapper>
2020-09-28 20:19:10 +08:00
</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';
import { PageWrapper } from '/@/components/Page';
2020-09-28 20:19:10 +08:00
export default defineComponent({
components: { Alert, Modal1, Modal2, Modal3, Modal4, PageWrapper },
2020-09-28 20:19:10 +08:00
setup() {
const [register1, { openModal: openModal1 }] = useModal();
2020-09-28 20:19:10 +08:00
const [register2, { openModal: openModal2 }] = useModal();
const [register3, { openModal: openModal3 }] = useModal();
2020-11-18 23:47:32 +08:00
const [register4, { openModal: openModal4 }] = useModal();
2020-09-28 20:19:10 +08:00
function send() {
2020-11-05 22:40:30 +08:00
openModal4(true, {
data: 'content',
info: 'Info',
});
2020-09-28 20:19:10 +08:00
}
function openModalLoading() {
openModal1(true);
// setModalProps({ loading: true });
// setTimeout(() => {
// setModalProps({ loading: false });
// }, 2000);
2020-09-28 20:19:10 +08:00
}
return {
register1,
openModal1,
register2,
openModal2,
register3,
openModal3,
register4,
openModal4,
send,
openModalLoading,
};
},
});
</script>