【问题标题】:Material-UI password input required需要输入 Material-UI 密码
【发布时间】:2018-09-06 03:50:30
【问题描述】:

使用 MUI @Next 和 TextField 组件。

当你添加 required 作为道具时,MUI 很好地在标签的末尾添加了一个小 *,但是当你添加 endAdornment 以启用“显示密码”切换。

我创建了a codesandbox of my issue

常规的<Texfield /> 组件按预期显示 *,但同样必需的密码字段没有。

【问题讨论】:

    标签: textfield material-ui


    【解决方案1】:

    在对我的问题进行代码和框复制时,我找到了答案,但我想我会把它留在这里给遇到这个问题的其他人。 required 属性必须放在输入的 <FormControl /> 包装器上:

    <FormControl required ... >
       <InputLabel ... >Password</InputLabel>
       <Input ... />
    </FormControl>
    

    【讨论】:

      猜你喜欢
      • 2019-11-28
      • 2020-10-30
      • 2020-04-10
      • 2021-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-03
      • 1970-01-01
      相关资源
      最近更新 更多