import React,{FC} from "react"
import "./cmtitem.scss"
type IProps={
id:number,
user:string,
content:string
}
const Cmittem:FC<IProps>=(props)=>{
const clickHandler=(event:React.MouseEvent)=>{
console.log("事件触发了",event)
}
return <div className="item" key="item.id">
<h1 className="title">评论人:{props.user}</h1>
<div className="content">{props.content}</div>
<button onClick={clickHandler}>点击按钮触发事件e</button>
</div>
}
export default Cmittem
这里的关键是event对象的类型是event:React.MouseEvent