React-antd selector selecciona múltiples atributos para pasar valores

1. Al usar el selector de selección, todos sabemos que podemos usar value值las propiedades seleccionadas para obtener.

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

Inserte la descripción de la imagen aquí

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

Inserte la descripción de la imagen aquí
2. Pero cuando necesitamos obtener múltiples valores de atributos, de hecho, el selector también tiene atributos opcionales para la selección.
Inserte la descripción de la imagen aquí
Entonces, cuando necesitamos obtener múltiples valores de atributos, podemos asignar el valor a title与className
3. Ejemplo:

 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,
    })
     
如此我们即可在回调函数中获取多个属性值

Supongo que te gusta

Origin blog.csdn.net/weixin_45416217/article/details/106870897
Recomendado
Clasificación