0
嘗試了我的第一次反應,但卡住了,想要做多重綁定。狀態未定義錯誤使用setState
class HelloWorldComponent extends React.Component {
constructor(props){
super(props);
this.state = {
price
}
}
render() {
return (
<div>
<input type="text" onChange={e => this.setState({price: e.target.value})} placeholder="main price"/>
<input type="text" placeholder="custom price"/>
</div>
);
}
}
我上面的代碼有什麼問題?價格沒有定義?我已經聲明
this.state = {
price
}
正確。我也在檢查一樣。我的答案在這裏是錯誤的。 – Ved