mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
fix: removeChild #121
This commit is contained in:
parent
a0b7597d58
commit
bf251f851d
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
/**
|
||||
* https://tobiasahlin.com/spinkit
|
||||
* https://connoratherton.com/loaders
|
||||
@ -45,12 +43,25 @@ export function useLoading() {
|
||||
|
||||
return {
|
||||
appendLoading() {
|
||||
document.head.appendChild(oStyle)
|
||||
document.body.appendChild(oDiv)
|
||||
safe.append(document.head, oStyle)
|
||||
safe.append(document.body, oDiv)
|
||||
},
|
||||
removeLoading() {
|
||||
document.head.removeChild(oStyle)
|
||||
document.body.removeChild(oDiv)
|
||||
safe.remove(document.head, oStyle)
|
||||
safe.remove(document.body, oDiv)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const safe = {
|
||||
append(parent: HTMLElement, child: HTMLElement) {
|
||||
if (!Array.from(parent.children).find(e => e === child)) {
|
||||
return parent.appendChild(child)
|
||||
}
|
||||
},
|
||||
remove(parent: HTMLElement, child: HTMLElement) {
|
||||
if (Array.from(parent.children).find(e => e === child)) {
|
||||
return parent.removeChild(child)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user