fixbug
This commit is contained in:
parent
cb382e5000
commit
84dcb3b42f
@ -20,6 +20,23 @@ const printTextWrod = ref(["FONCHAT", "Let's Chat", "Let's Create", "Let's Go"])
|
|||||||
const backgroundColor = ref(['red', 'blue', '#f3f4f6', '#f3f4f6'])
|
const backgroundColor = ref(['red', 'blue', '#f3f4f6', '#f3f4f6'])
|
||||||
let printInterval = null
|
let printInterval = null
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
textEffect()
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
clearInterval(printInterval)
|
||||||
|
})
|
||||||
|
// 解决离开页面文字堆叠
|
||||||
|
document.addEventListener('visibilitychange', function () {
|
||||||
|
if (document.hidden) {
|
||||||
|
clearInterval(printInterval)
|
||||||
|
document.querySelector('#chat').innerText = ''
|
||||||
|
} else {
|
||||||
|
clearInterval(printInterval)
|
||||||
|
textEffect()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 文字特效逻辑
|
||||||
|
function textEffect() {
|
||||||
printText(printTextWrod.value[0])
|
printText(printTextWrod.value[0])
|
||||||
let index = 1
|
let index = 1
|
||||||
printInterval = setInterval(() => {
|
printInterval = setInterval(() => {
|
||||||
@ -30,10 +47,7 @@ onMounted(() => {
|
|||||||
index++
|
index++
|
||||||
document.querySelector('#chat').innerText = ''
|
document.querySelector('#chat').innerText = ''
|
||||||
}, 2500)
|
}, 2500)
|
||||||
})
|
}
|
||||||
onUnmounted(() => {
|
|
||||||
clearInterval(printInterval)
|
|
||||||
})
|
|
||||||
function login() {
|
function login() {
|
||||||
router.push('/')
|
router.push('/')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user