mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
35 lines
902 B
TypeScript
35 lines
902 B
TypeScript
import { defineComponent, h, createApp, resolveComponent, reactive, ComponentOptions } from 'vue'
|
|
|
|
import { VxeModalDefines } from '../../types/all'
|
|
|
|
let dynamicContainerElem: HTMLElement
|
|
|
|
export const dynamicStore = reactive({
|
|
modals: [] as VxeModalDefines.ModalOptions[]
|
|
})
|
|
|
|
/**
|
|
* 动态组件
|
|
*/
|
|
const VxeDynamics = defineComponent({
|
|
setup () {
|
|
return () => {
|
|
const { modals } = dynamicStore
|
|
return h('div', {
|
|
class: 'vxe-dynamics--modal'
|
|
}, modals.map((item) => h(resolveComponent('vxe-modal') as ComponentOptions, item)))
|
|
}
|
|
}
|
|
})
|
|
|
|
export const dynamicApp = createApp(VxeDynamics)
|
|
|
|
export function checkDynamic () {
|
|
if (!dynamicContainerElem) {
|
|
dynamicContainerElem = document.createElement('div')
|
|
dynamicContainerElem.className = 'vxe-dynamics'
|
|
document.body.appendChild(dynamicContainerElem)
|
|
dynamicApp.mount(dynamicContainerElem)
|
|
}
|
|
}
|