import React, { Component } from 'react' const xhh = require('@/public/xhh.jpeg') /**错误边界捕获*/ function HocError(Element: any) { return class ErrorBoundary extends Component { constructor(props:any){ super(props) } state = { hasError: false } static getDerivedStateFromError(error: any) { return { hasError: true } } componentDidCatch(...err: any) { // 你同样可以将错误日志上报给服务器 console.log(...err); } render() { let { hasError } = this.state if (hasError) { return <>
恭喜你发现了一个BUG,请保护BUG现场,钉钉联系沈武!
} return } } } export default HocError