【问题标题】:Material UI Select displayEmpty label covers inputMaterial UI 选择 displayEmpty 标签覆盖输入
【发布时间】:2019-08-28 13:57:19
【问题描述】:

我很难选择这个选项。看起来displayEmpty 道具可能存在错误。我尝试了以下方法,但是当value === ""

        <FormControl>
          <InputLabel htmlFor="profile-select">Profile</InputLabel>
          <Select
            value={values.accessProfile}
            onChange={handleChange("accessProfile")}
            input={<Input id="profile-select" />}
            displayEmpty
          >
            <MenuItem value={""}>None</MenuItem>
            {profiles.map(profile => (
              <MenuItem value={profile.id}>{profile.name}</MenuItem>
            ))}
          </Select>
        </FormControl>

【问题讨论】:

  • 你能提供一个codepen吗?

标签: reactjs material-ui


【解决方案1】:

您需要将 InputLabel 组件上的 shrink 属性设置为 true https://material-ui.com/api/input-label/

【讨论】:

    猜你喜欢
    • 2020-08-10
    • 2020-01-01
    • 1970-01-01
    • 2020-08-07
    • 1970-01-01
    • 2021-01-17
    • 1970-01-01
    • 2018-10-26
    • 2020-01-30
    相关资源
    最近更新 更多