无法从反应dom调用的方法

时间:2018-02-21 17:19:28

标签: reactjs

listItems 出现在render()中。所有功能都运行良好。 我试图点击该行然后它将执行 projectDetails()。但它显示如下错误:

enter image description here

在render()

var listItems = this.state.projectList.map(function (item, index) {
                return <tr key={index} onClick={this.projectDetails(item, index)}>
                    <td>{item.name}</td>
                    <td>{item.description}</td>
                    <td><i className="glyphicon glyphicon-trash"  onClick={
                        function() {
                            showconfrim("Do you want to delete this Project?");
                        }
                    }></i></td>
                </tr>
            });

方式

 projectDetails(item, index) {
        console.log(index);
    }

构造

constructor(props) {
        super(props);

        this.state = {
            activePage: 1,
            projectList: []
        };

        this.projectDetails = this.projectDetails.bind(this);
    }

0 个答案:

没有答案