我正在使用 react.js 開發(fā)事件 crud 應(yīng)用程序,但出現(xiàn)此錯(cuò)誤:TypeError:this.props.onDelete 不是函數(shù)這是用戶界面:這是我點(diǎn)擊刪除時(shí)的錯(cuò)誤:當(dāng)我點(diǎn)擊編輯時(shí),我也會(huì)遇到同樣的錯(cuò)誤。這是代碼:import React, { Component } from "react";class Event extends Component { onDelete = () => { // console.log('event ', this.props.event.id); this.props.onDelete(this.props.id); }; onEdit = () => { // console.log('event ', this.props.event.id); this.props.onEdit(this.props); }; render() { const { id, eventname, eventdescription } = this.props.event; return ( <tr> <td>{id}</td> <td>{eventname}</td> <td>{eventdescription}</td> <td> <button onClick={this.onEdit}>Edit</button> <button onClick={this.onDelete}>Delete</button> </td> </tr> ); }}export default Event;
TypeError:this.props.onDelete 不是函數(shù)
白板的微信
2022-05-22 11:25:50