0
...
class AddForm extends Component {
constructor() {
super();
}
getValue() {
let refsValue = [{
\t price: this.refs.price.value,
\t remarks: this.refs.remarks.value
}];
return refsValue;
}
render() {
return (
<div>
<input type="number" name="price" ref="price" />
<input type="text" name="remarks" ref="remarks" />
</div>
);
}
}
class BankForm extends Component {
constructor() {
super();
this.onSubmit = this.onSubmit.bind(this);
}
onSubmit() {
console.log(getValue());
}
render() {
return (
<div>
<button onClick={ this.onSubmit }>Submit</button>
</div>
);
}
...
如何從的getValue返回的onsubmit?
getValue() { ... return refsValue; } -> onSubmit() { console.log(getValue()) }
請更正onSubmit的內容!
對不起我英語不好
嗯...... PLZ例如 –
完成,用小提琴。如果這對你有幫助,請接受我的回答,謝謝! – ggilberth
Thx您的親切答案 –