import React, { useCallback, useEffect, useRef, useState } from 'react' import styles from './index.module.scss' import classNames from 'classnames' import { baseURL, myData } from '@/utils/http' import { domDelOwnFu } from '@/utils/utilsSome' type Props = { isShow: boolean //是否显示 iconSrc: string //icon 图标 parentFu: () => void //点击继续的方法(调用父亲) bgImg?: string num?: number } function BaseImg({ isShow, iconSrc, parentFu, bgImg, num = 30 }: Props) { const [loding, setLoding] = useState(myData.isLdong ? 0 : 100) const timeRR = useRef(-1) useEffect(() => { clearInterval(timeRR.current) timeRR.current = window.setInterval(() => { if (loding >= 100) { clearInterval(timeRR.current) return } setLoding(loding + 2) }, num) }, [loding, num]) const btnStartFu = useCallback(() => { if (loding >= 100) { parentFu() // 0.5s之后删除自己 setTimeout(() => { domDelOwnFu('#BaseImg') }, 500) } }, [loding, parentFu]) return (