init
This commit is contained in:
26
src/hooks/useBackgroundHook.ts
Normal file
26
src/hooks/useBackgroundHook.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import {onMounted, onUnmounted} from "vue";
|
||||
|
||||
export const useBackgroundHook = () => {
|
||||
|
||||
|
||||
let bodyList = document.getElementsByTagName('body');
|
||||
let body = bodyList[0]
|
||||
let bodyBackground = body.style.background
|
||||
|
||||
|
||||
const setBodyBackground = (option?: {mounted?: Function | undefined, unmounted?: Function | undefined}) => {
|
||||
let {mounted, unmounted} = option || {}
|
||||
|
||||
onMounted(() => {
|
||||
body.style.background = 'linear-gradient(167.96deg, #E6FAE1 0%, #F2E7B7 98.44%) no-repeat'
|
||||
mounted && mounted()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
body.style.background = bodyBackground
|
||||
unmounted && unmounted()
|
||||
})
|
||||
}
|
||||
|
||||
return { setBodyBackground }
|
||||
}
|
||||
Reference in New Issue
Block a user