错误写法:
const handleSubmit = (event: React.FormEventHandler<HTMLFormElement>)=>{
console.log(event)
}
return <form onSubmit={handleSubmit}></form>
FormEventHandler是处理表单元素的
FormEvent是处理事件(event)的
正确写法:
const handleSubmit = (event: React.FormEvent<HTMLFormElement>)=>{
console.log(event)
}
return <form onSubmit={handleSubmit}></form>
或者
const handleSubmit: React.FormEventHandler<HTMLFormElement> = (event: React.FormEvent<HTMLFormElement>)=>{
console.log(event)
}
return <form onSubmit={handleSubmit}></form>