mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-12 10:45:10 +08:00
23 lines
613 B
TypeScript
23 lines
613 B
TypeScript
|
import { onBeforeMount } from 'vue'
|
||
|
import { isClient } from '@vueuse/core'
|
||
|
import { generateId } from '@element-plus/utils/util'
|
||
|
|
||
|
let cachedContainer: HTMLElement
|
||
|
|
||
|
export const POPPER_CONTAINER_ID = `el-popper-container-${generateId()}`
|
||
|
|
||
|
export const POPPER_CONTAINER_SELECTOR = `#${POPPER_CONTAINER_ID}`
|
||
|
|
||
|
export const usePopperContainer = () => {
|
||
|
onBeforeMount(() => {
|
||
|
if (!isClient) return
|
||
|
|
||
|
if (!cachedContainer) {
|
||
|
const container = document.createElement('div')
|
||
|
container.id = POPPER_CONTAINER_ID
|
||
|
document.body.appendChild(container)
|
||
|
cachedContainer = container
|
||
|
}
|
||
|
})
|
||
|
}
|