解決辦法: 最外層元素增加fixed 佈局即可
2. ios input輸入 頁面會放大,收起時頁面不自動還原
解決辦法 input 字型設定最小為16px即可
3.網頁標籤切換獲取切換狀態
document.addEventListener("visibilitychange", visibleChangeFun);
const visibleChangeFun= ()=>{
if (document.visibilityState === "hidden"){
//隱藏
}
if (document.visibilityState === "hidden"){
//隱藏
}
}
4.倒數計時要用本地時間處理,不然切頁面定時器不執行,時間不準確
const [timeLeft, setTimeLeft] = useState<any>(); const [startTime, setStartTime] = useState<any>(new Date().getTime()); useEffect(() => { timer = setInterval(() => { setTimeLeft((prevTimeLeft: number) => prevTimeLeft - 1000); }, 1000); return () => { clearInterval(timer); }; }, [expires]); useEffect(() => { if (expires) { setTimeLeft(expires); setStartTime(new Date().getTime()); } }, [expires]) useEffect(() => { if (timeLeft + startTime <= new Date().getTime()) { timer && clearInterval(timer); } }, [timeLeft]);