【问题标题】:Material-UI OutlinedInput does not show the startAdornmentMaterial-UI OutlinedInput 不显示 startAdornment
【发布时间】:2021-12-28 05:01:07
【问题描述】:

以下是代码。开始装饰不会出现在文本字段中。此外,标签不显示任何文字。

<InputLabel>Mobile Number</InputLabel>
            <OutlinedInput
              variant="outlined"
              autoComplete="outlined"
              name="name"
              required
              fullWidth
              label="Enter Mobile Number"
              autoFocus
              inputProps={{
                maxLength: 10,
              }}
              InputProps={{
                startAdornment: (
                  <InputAdornment position="start">+1 </InputAdornment>
                ),
              }}
            />

【问题讨论】:

    标签: javascript reactjs material-ui


    【解决方案1】:

    将 TextField 用于 startAdorment 并删除 inputlabel 并将您的愿望标签作为道具传递给 TextField :

     <TextField
                  variant="outlined"
                  autoComplete="outlined"
                  name="name"
                  required
                  fullWidth
                  label="Enter Mobile Number"
                  autoFocus
                  InputProps={{
                    startAdornment: (
                      <InputAdornment position="start">+1 </InputAdornment>
                    ),
                  }}
                />
    

    或者,如果您想使用 OtlinedInput,您可以将其作为道具传递:

      startAdornment={
                <InputAdornment position="start">
                  <AccountCircle />
                </InputAdornment>
              }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-27
      • 2019-05-25
      • 2020-04-16
      • 1970-01-01
      • 2019-06-16
      • 2021-10-21
      • 2019-11-19
      相关资源
      最近更新 更多