javascript - React develops table components by itself. How to get the ID of the current row when clicking within a row?
淡淡烟草味
淡淡烟草味 2017-05-19 10:25:02
0
2
803
class ManageTable extends Component{
showModal(){

}
render(){
    return(
        <tr id={user.id}>
        <td>{}</td>
        <td>{}</td>
        <td>{}</td>
        <td>{}</td>
        <td ref="viewDatail"><a onClick={this.showModal}>查看详情</a></td>
        </tr>
        )
    }
}

export default ManageTable;

Click to view details, how to get the ID of the current row.

I want to complete the next step. The first step is to obtain the ID. How to achieve this?
Seek the guidance of the great God.

淡淡烟草味
淡淡烟草味

reply all(2)
phpcn_u1582
showModal(event) {
    event = event.nativeEvent;
    const tr = event.target.parentNode;
    console.log(tr.id);
}
大家讲道理

Try it:
<td ref="viewDatail"><a onClick={this.showModal.bind(this)}>查看详情</a></td>

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template