12345678910111213141516171819202122232425262728293031323334353637 |
- import { createApp, h, onMounted, ref } from 'vue'
- import { Modal } from 'ant-design-vue'
- export function openModal(contentComp: any, contentProps: any, modalProps?: any) {
- const newElement = document.createElement('div')
- document.getElementById('app')?.appendChild(newElement)
- const openModal = ref(true)
- const app = createApp({
- setup(props, content) {
- return () => {
- return h(
- Modal,
- {
- open: openModal.value,
- title: '标题',
- ...modalProps,
- destroyOnClose: true,
- cancelText: '取消',
- okText: '确定',
- onCancel: () => {
- openModal.value = false
- },
- onOk: () => {
- if (modalProps.onOk) {
- console.log(document.getElementsByClassName('contentRef'))
- modalProps.onOk()
- } else {
- openModal.value = false
- }
- }
- },
- () => h(contentComp, { ref: 'contentRef', ...contentProps })
- )
- }
- }
- })
- app.mount(newElement)
- }
|