我有如下代码(我在前端使用 react-admin);
<ReferenceInput label="DataPoint Types" source="datapointtype" reference="datapointtypes" onChange={this.dptChanged}>
<SelectInput optionText="id" />
</ReferenceInput>
<ArrayInput source='parameters'>
<SimpleFormIterator>
<TextInput source='id' label="name" validate {this.validateParameterName} />
<ReferenceInput label="Parameter DataType" source="parameters" reference="datatypes">
<SelectInput optionText="id" source="id" />
</ReferenceInput>
</SimpleFormIterator>
</ArrayInput>
改变功能;
dptChanged(event) {
const dataPointType = Object.values(event).slice(0, -1).join('');
axios.get('http://localhost:3001/designer/datapointtypes/' + dataPointType)
.then(response => {
if (response.data.parameters) {
this.setState({
connectedParameters: Object.values(response.data.parameters)
})
}
});
axios.get('http://localhost:3001/designer/datatypes')
.then(response => {
this.setState({
datatypes: response.data
})
})
}
我想做的事情就是这样;当我更改 SelectInput(数据点类型)时,“参数”ArrayInput 必须为空,即使它有元素。
我怎样才能做到这一点?