feat: support loading

This commit is contained in:
草鞋没号 committed 2021-11-02 10:19:50 +08:00
1 parent ad9e8a4937
commit 62531ae987
5 files changed
+104 -2

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
/** 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)
}
})
}
})
}