export class ProjectList extends Component{
constructor(props){
super(props)
this.state={
project:[],
}
}
componentDidMount(){
axios.get("http://127.0.0.1:9090/pro/pList").then(res =>{
this.setState({
project:res.data.page.datas
})
})
}
render(){
return (
<Select key="project" style={{width:"100%"}} placeholder="">
{
this.state.project.map((item,i) =>{
return(
<Option key={`project${i}`} value={item.id}>{item.name}</Option>
)
})
}
</Select>
)
}
}
class AddOrderType extends Component{
render(){
return(
<Modal
title=""
wrapClassName="vertical-center-modal"
visible={this.props.ishow}
onOk={this.handleOk}
onCancel={this.handleCancel}
footer={[
<Button key="back" size="large" onClick={this.handleCancel}></Button>,
<Button key="submit" type="primary" size="large" loading={loading} onClick={this.handleOk}>
</Button>,
]}
>
<FormItem
{...formItemLayout}
label=""
>
{getFieldDecorator("project",{
rules: [{
required: true,
message: "!"
}],
})(<ProjectList values={this.state.values} onChange={this.onChange} />)}//
</FormItem>
</Modal>
)
}
}
now it"s a pop-up box that contains a select like this because this select is used in a lot of places, so I encapsulated the select again. Now the pop-up box is normal and the select component is normal, but when the user manipulates the select and closes the pop-up box and opens it again, the value of the select is the value of the last operation and has not been reset. If you assign a value with value, it will cause select to become inoperable. If you use defaultValue, it will only work when it is loaded for the first time.
* *
< H2 > Don"t just say some theoretical things, such as ambiguous answers such as props reset, please give a reasonable answer after practice. < / H2 >* *