formik array

      <Grid item xs={COLUMN_WIDTH}>
            {
              <FieldArray
                name='lanes'
                render={(arrayHelpers: any) => (
                  <React.Fragment >
                    <FormControl fullWidth>
                      <InputLabel>车道3</InputLabel>
                      <Select
                        name={`laneNo`}
                        label="转向"
                        value={formik.values.lanes[currentLaneIndex].laneNo}
                        onChange={formik.handleChange}
                        onBlur={formik.handleBlur}
                      >{
                          formik.values.lanes.map((lane: any, index: number) => (
                            <MenuItem value={lane.laneNo} key={index}>{lane.laneNo}</MenuItem>
                          ))
                        }
                      </Select>
                    </FormControl>
                  </React.Fragment>
                )}
              />
            }
          </Grid>
          <Grid item xs={COLUMN_WIDTH}>
            <FormControl fullWidth>
              <InputLabel>转向2</InputLabel>
              <Select
                name={`laneFeature`}
                value={formik.values.lanes[currentLaneIndex].laneFeature}
                label="转向"
                onChange={formik.handleChange}
                onBlur={formik.handleBlur}
              >
                {
                  formik.values.lanes.map((lane: any, index: number) => (
                    <MenuItem value={lane.laneFeature} key={index}>{lane.laneFeature}</MenuItem>
                  ))
                }
              </Select>
            </FormControl>
          </Grid>

 

posted @ 2022-06-24 15:50  古德拉克  阅读(22)  评论(0编辑  收藏  举报