【问题标题】:Material UI InputAdornment not showing anythingMaterial UI InputAdornment 没有显示任何东西
【发布时间】:2021-12-31 16:51:54
【问题描述】:

我是第一次在一个项目中使用 MUI。试图让 InputAdornment 在 TextInput 中显示放大镜 svg 图标。我在这里遵循示例:https://mui.com/components/text-fields/

无论装饰的内容如何,​​我都无法在 UI 中显示任何内容。在检查器中,输入的装饰属性看起来像这样endadornment="[object Object]"

我的代码是这样的:

<TextField
    defaultValue={''}
    inputProps={{
        placeholder: 'Search',
        endAdornment: <InputAdornment position="end">any</InputAdornment>
    }}
    onChange={handleChange}
/>

【问题讨论】:

  • 您是否尝试过将 endAdornment 传递给 InputProps 而不是 inputProps?它们是应用于不同子组件的不同道具...
  • 哇,我无语了。就是这样。而且这个命名也很可怕。谢谢!

标签: reactjs material-ui next.js


【解决方案1】:

cris_b 在评论中回答。原来在 TextField 上有一个 InputProps 道具和一个 inputProps 道具。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多