handleClick=()=>{
console.log("final course values"+ " "+this.state.selectCourseValue)
console.log("selected teacher"+ " "+this.state.selectedTeacher)
if(this.state.selectCourseValue ===null && this.state.selectedTeacher !== undefined)
{
console.log("please select")
message.warning('Add course')
return;
}
else{
console.log("Sucessfully updated")
}
}
答案 0 :(得分:1)
如果selectCourseValue
是一个数组,那么您的条件可能应该是这样:
if (this.state.selectedTeacher && (this.state.selectCourseValue || []).length === 0) {
}
检查selectedTeacher
是否为空并且selectCourseValue
为空。