React-antd selector selects multiple attributes to pass values

1. When using the Select selector, we all know that we can use value值the selected properties to get.

默认根据此属性值进行筛选 

Insert picture description here

function handleChange(value) {
    
    
  console.log(`selected ${
      
      value}`);
}

Insert picture description here
2. But when we need to get multiple attribute values, in fact, the selector also has optional attributes for selection.
Insert picture description here
So when we need to get multiple attribute values, we can assign the value to title与className
3. Example:

 return (
          <Option value={
    
    index} title={
    
    item.startDate} className={
    
    item.endDate} key={
    
    }>{
    
    `${
      
      item.year}-${
      
      item.endYear}学年${
      
      item.semester}`}</Option>
        )

  handleChangeSemester = (value, e) => {
    
    
    const {
    
    
      attendanceStatisticsSection: {
    
     semesterTime },
    } = this.props;
    // 将学期范围和学期码传入下一页面
    this.setState({
    
    
      startDateRange: e.props.title,
      endDateRange: e.props.className,
      initSemesterCode: semesterTime[value].semesterCode,
    })
     
如此我们即可在回调函数中获取多个属性值

Guess you like

Origin blog.csdn.net/weixin_45416217/article/details/106870897