404页面处理

This commit is contained in:
tangly1024
2022-04-26 10:43:35 +08:00
parent fa4abada58
commit 17c34d78f5

View File

@@ -1,6 +1,22 @@
import LayoutBase from './LayoutBase'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
export const Layout404 = props => {
const router = useRouter()
useEffect(() => {
// 延时3秒如果加载失败就返回首页
setTimeout(() => {
if (window) {
const article = document.getElementById('container')
if (!article) {
router.push('/').then(() => {
console.log('找不到页面', router.asPath)
})
}
}
}, 3000)
})
return (
<LayoutBase {...props}>
<div className="text-black w-full h-screen text-center justify-center content-center items-center flex flex-col">