我怎樣才能啓用按鈕只有當所有的領域被添加?我可以做到這一點,如果我必須檢查一個領域,但在這裏我有多個領域也選擇領域。這就是爲什麼我不知道如何做到這一點。這裏是形式我做啓用按鈕僅當所有表格填充後才能點擊
class Registration extends React.PureComponent {
state = {
valueOfCategory: 1,
valueOfPlatform: '',
};
handleCategoryChange = (event, index, value) => this.setState({valueOfCategory: value});
handlePlatformChange = (event, index, value) => this.setState({valueOfPlatform: value});
addPlatform = (event, index, value) => this.setState({ platform: value });
addCategory = (event, index, value) => this.setState({ category: value });
render() {
return (
<div className="registration">
<Card>
<TextField
type="text"
hintText="Bot name"
/><br />
<TextField
type="text"
hintText="Location"
/><br />
<SelectField
value={this.state.valueOfCategory}
onChange={this.handleCategoryChange}
hintText="Category"
>
<MenuItem value={1} primaryText="Food" />
<MenuItem value={2} primaryText="Travel" />
<MenuItem value={3} primaryText="Communication" />
</SelectField>
<FloatingActionButton onTouchTap={this.addCategory}><ContentAdd /></FloatingActionButton>
<br/>
<SelectField
value={this.state.valueOfPlatform}
onChange={this.handlePlatformChange}
hintText="Platform"
>
<MenuItem value={1} primaryText="Facebook" />
<MenuItem value={2} primaryText="KIK" />
<MenuItem value={3} primaryText="Slack" />
</SelectField>
<FloatingActionButton onTouchTap={this.addPlatform}><ContentAdd /></FloatingActionButton>
<br/>
{this.state.valueOfPlatform === 1 && <FacebookPlatform />}
<RaisedButton label="Done" />
</Card>
</div>