在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
define interface: interface ILoginState {
imageId: string;
imageSrc: string;
username: string;
password: string;
verifyCode: string;
}
useState: const [loginData, setLoginData] = useState(loginState) update imageId && imageSrc: setLoginData({
...loginData,
imageId: res.data.id.
imageSrc: res.data.content
})
antd inputchange: onInputChange(e: FormEvent<HTMLInputElement>) { const inputName = e.currentTarget.id; const inputValue = e.currentTarget.value; setInputData({ [inputName]: inputValue } as {[key in keyof ILoginState]:ILoginState[key]}) } antd form onsubmit <Form onSubmit={handleSubmit.bind(this)}> add window resizeLitener const [contentHeight, setHeight]=useState(INTIAL_HEIGHT) useEffect(()=>{ screenChange(); return () => removeListener()//回调销毁 },[contentHeight]) const screenChange = () => { window.addEventListener("resize", handleResize) } const removeListener = () => { window.removeEventListener("resize", handleResize) } handleResize =(e)=> { setHeight(e.target.innerHeight-headerHeight-footerHeight) }
|
请发表评论