Open fangmd opened 1 year ago
const [userInfo, setUserInfo] = useState({ username: "", age: "", gender: "", email: "", password: "", address: "", city: "" }); const onChange = (e) => { setUserInfo((pre) => ({ ...pre, [e.target.name]: e.target.value })); }; <input type="text" name="age" placeholder="age" onChange={onChange} />
react 表单简化