1. import React,{FC} from "react"
    2. import "./cmtitem.scss"
    3. type IProps={
    4. id:number,
    5. user:string,
    6. content:string
    7. }
    8. const Cmittem:FC<IProps>=(props)=>{
    9. const clickHandler=(event:React.MouseEvent)=>{
    10. console.log("事件触发了",event)
    11. }
    12. return <div className="item" key="item.id">
    13. <h1 className="title">评论人:{props.user}</h1>
    14. <div className="content">{props.content}</div>
    15. <button onClick={clickHandler}>点击按钮触发事件e</button>
    16. </div>
    17. }
    18. export default Cmittem

    这里的关键是event对象的类型是event:React.MouseEvent