Javascript 多重搜索选择下拉列表
请告诉我,如何在多搜索选择下拉列表中设置defaultValue?我试图在文档中设置类似于描述的对象数组,但我并没有收到我想要的Javascript 多重搜索选择下拉列表,javascript,reactjs,semantic-ui-react,Javascript,Reactjs,Semantic Ui React,请告诉我,如何在多搜索选择下拉列表中设置defaultValue?我试图在文档中设置类似于描述的对象数组,但我并没有收到我想要的 constructor(props) { super(props); this.state = { specs: [], doctorSpecs: [] } this.profileService = new ProfileService(); this.addSpecializationsService = new Spe
constructor(props) {
super(props);
this.state = {
specs: [],
doctorSpecs: []
}
this.profileService = new ProfileService();
this.addSpecializationsService = new SpecializatoinsService();
}
componentWillMount() {
this.profileService.getProfileInformation()
.then((res) => {
this.setState({
profile: res.data,
consultationFees: res.data.consultation_fees,
mpdbRegistrationNumber: res.data.mpdb_registration_number,
qualification: res.data.qualification,
experienceYears: res.data.experience_years,
doctorSpecs: res.data.specializations.map((elem, index) => {
return {key: index, value: elem.id, text: elem.name}
})
})
})
this.addSpecializationsService.getSpecializationsList("", (res) => {
console.log(res);
this.setState({
specs: res.data.body.map((elem, index) => {
return {key: elem.id, value: elem.id, text: elem.name}
})
})
});
}
// other nessesary code
// component where must be this.state.doctorSpecs
<Dropdown
className='profile-specs'
placeholder='Skills'
fluid multiple selection search
options={this.state.specs}
onChange={this._onChangeSpecs}
value={this.state.doctorSpecs}
onSearchChange={this._getListSpecs}/>
构造函数(道具){
超级(道具);
此.state={
规格:[],
博士学位:[]
}
this.profileService=new profileService();
this.addSpecializationsService=新的SpecializationInsService();
}
组件willmount(){
this.profileService.getProfileInformation()
。然后((res)=>{
这是我的国家({
资料简介:res.data,
咨询费:资源数据咨询费,
mpdb注册号:res.data.mpdb\u注册号,
资格:res.data.qualification,
经验年数:res.data.experience\u年数,
doctorSpecs:res.data.specializations.map((元素,索引)=>{
返回{key:index,value:elem.id,text:elem.name}
})
})
})
this.addSpecializationsService.getSpecializationsList(“,(res)=>{
控制台日志(res);
这是我的国家({
规格:res.data.body.map((元素,索引)=>{
返回{key:elem.id,value:elem.id,text:elem.name}
})
})
});
}
//其他必要代码
//组件,其中必须是this.state.doctorSpecs
我希望在渲染组件之后,在此下拉列表中显示值数组
我尝试使用value,defaultValue,但它不起作用我发现了一个问题。
我必须转移到数组中的不是对象,而是来自此对象的文本值向我们显示您在编辑问题时使用的代码