React 是否有一种简洁的方法从列表项中获取 this.props.values?
我基本上想获取当前项目 Prop ,以便我可以用数据填充模式对话框。按照下面的功能,我指定的自定义 Prop (如“id”)是可以访问的,但我真的很想做这样的事情并拥有所有 Prop
event.currentTarget.this.props.note
处理程序
clicker(event){
console.log('clicking the clicker');
console.log(event.currentTarget.id);
this.setState({isEdit: true});
console.log(this.state.isEdit);
}
查看
<div id={this.props.id} onClick={this.clicker} className="aui-item page-card off-track notecards">
<div className="project-details">
<div className="card-container">
<div className="left">
<h6>Title</h6>
<span>{this.props.note.content}</span>
<h6 className="compact">Last status report</h6>
<span>{this.props.note.updatedAt}</span>
</div>
<div className="right">
<span>something</span>
</div>
</div>
</div>
</div>
最佳答案
您可以直接访问clicker中的 Prop
clicker(event){
console.log('clicking the clicker');
console.log(this.props.id);
this.setState({isEdit: true});
console.log(this.state.isEdit);
}
关于javascript - react 如何从 event.currentTarget 获取项目 Prop ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38549287/