0
我有一个React应用程序,我正在学习React,它增加了收入,支出和日志事务。如何在此React应用程序中设置编辑项目功能?
我很担心如何设置编辑条目的能力。
所以我有一系列的每个条目。支出项阵营等级如下表所示:
const Expenditure = React.createClass({
renderExpenditure(key) {
const details = this.props.cashbook[key];
return(
<tr className="item" key={key}>
<td><strong>{details.name}</strong></td>
<td><strong>{h.formatPrice(details.amount)}</strong></td>
<td>{details.category}</td>
<td>{details.type}</td>
<td>{details.date}</td>
<td><button className="remove-item" onClick={this.props.removeCashflow.bind(null, key, 'expenditure')}>Remove</button></td>
</tr>
);
},
render() {
return(
<div className="expenditure">
<table id="exp-table">
<tbody>
{Object.keys(this.props.cashbook || {}).map(this.renderExpenditure)}
</tbody>
</table>
</div>
);
}
});
而且removeCashflow,在主应用程序组件,看起来像:
removeCashflow(key, type) {
this.state.cashbook[type][key] = null;
this.setState({
cashbook: { [type]: this.state.cashbook[type] }
});
},
没有人有任何指针或建议,以建立最好的办法在React中编辑条目的能力?
不确定从哪里开始。
谢谢:)
谢谢@Mijamo - 我不能完全锻炼这将如何设置...这将取代'{Object.keys(this.props.cashbook || {})。map(this.renderExpenditure)}' ? –
准确地说,它将被替换为 {Object.keys(this.props.cashbook || {})。map(function(key){return })} –
Mijamo
你明星,谢谢你,会给这个bash! –