mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 20:07:06 +08:00
16 lines
402 B
TypeScript
16 lines
402 B
TypeScript
|
|
||
|
/** docoment ready */
|
||
|
export function domReady(condition: DocumentReadyState[] = ['complete', 'interactive']) {
|
||
|
return new Promise(resolve => {
|
||
|
if (condition.includes(document.readyState)) {
|
||
|
resolve(true)
|
||
|
} else {
|
||
|
document.addEventListener('readystatechange', () => {
|
||
|
if (condition.includes(document.readyState)) {
|
||
|
resolve(true)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
}
|