标签:str ges style state inpu ilog form div utc
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]}) }
react: typescript interface useState issue
标签:str ges style state inpu ilog form div utc
原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/11230813.html