所以我有一个包含多个选项的表单。 The form I have
我从发送行动的年份中选择一个选项,并进行api调用以获取显示的品牌列表。
如果我选择一个品牌并尝试选择另一个品牌,那么在选择品牌时是否还需要再打一次api?但是显示了相同的品牌列表?
在我的渲染函数中:
<div className='form-div'>
<Select defaultValue='-Year-' style = {{width:262}} className = 'formInput' onChange={this.handleYearSelection.bind(this)}>
{getYear(this.props.year)}
</Select>
</div>
<div className='form-div'>
<Select defaultValue='Brand' disabled={!this.state.brandVisibility} style = {{width:129}} className = 'formInput' onChange={this.handleBrandSelection.bind(this)}>
{getBrand(this.props.brand)}
</Select>
<Select defaultValue='Model' disabled={!this.state.modelVisibility} style = {{width:129}} className = 'formInput' onChange={this.handleModelSelection.bind(this)}>
{getModel(this.props.model)}
</Select>
</div>
渲染功能之前:
handleYearSelection(year){
this.setState({brandVisibility : true, year: year});
this.props.requestYear(year);
}
handleBrandSelection(brand){
this.setState({modelVisibility : true, brand: brand });
this.props.requestBrand(brand);
}
那么,我该如何解决呢?