2 回答
TA贡献1796条经验 获得超7个赞
试试下面,可能对你有用:
this.props.getAvailableteachers()
.then(() => {
if (this.props.teachers.length === 1) {
console.log(this.props.teachers);
this.setState({selectedId : set_your_id_here})
} else {
console.log("Length is >>>>>>>>>> 1");
} })
.catch(err => console.log(err));
和选择表格
type='text'
name='teachers'
colSize='8'
id='teachers'
onChange={this.teacherChange}
options={teacherOptions}
selected={this.state.selectedId}
/>
TA贡献1871条经验 获得超8个赞
只需将道具数据分配给value属性,如下所示
type='text'
name='teachers'
colSize='8'
id='teachers'
onChange={this.teacherChange}
options={teacherOptions}
value={this.props.teachers}
selected={this.props.teachers}
/>
添加回答
举报