倒计时reacthooks 叫我富察傅恒 2021-10-21 273 阅读1分钟 const [count, setCount] = useState(60); ... useEffect(() => { setTimeout(() => { if (count > 0) { setCount((num) => num - 1); } }, 1000); }, [count]); ... <Button onClick={() => setCount(10)}>dianwo</Button>