1.ios input 键盘收起页面底部有间隙没有自动还原
解决办法: 最外层元素增加fixed 布局即可
2. ios input输入 页面会放大,收起时页面不自动还原
解决办法 input 字体设置最小为16px即可
3.网页标签切换获取切换状态
document.addEventListener("visibilitychange", visibleChangeFun);
const visibleChangeFun= ()=>{
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]);
标签:const,expires,ios,input,useEffect,页面 From: https://www.cnblogs.com/xiaoyaoweb/p/18516604