import { useState, useEffect } from 'react';

const SiteRuntime = () => { const [uptime, setUptime] = useState(0);

useEffect(() => { const startTime = Date.now(); const interval = setInterval(() => { setUptime(Math.floor((Date.now() - startTime) / 1000)); }, 1000); return () => clearInterval(interval); }, []);

return (

Site runtime: {uptime} seconds

); };

export default SiteRuntime;

Nextjs 13 ts 写一个 网站运行时间

原文地址: https://www.cveoy.top/t/topic/bsPz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录