Cra*_*tCZ 2 javascript css underline reactjs material-ui
我想用没有下划线的Autocomplete组件创建TextField。InputProps={{ disableUnderline: true }}我已经禁用了在道具中使用下划线TextField,它完成了它的工作,但它也删除了选择栏,所以问题是,如何在不删除选择栏的情况下完成此操作?
要再次启用下拉列表,您还需要在嵌套属性中展开所有提供的 props ( InputProps)。所以替换这一行
<TextField {...params} InputProps={{ disableUnderline: true }} />
Run Code Online (Sandbox Code Playgroud)
和:
<TextField {...params} InputProps={{ ...params.InputProps, disableUnderline: true }} />
Run Code Online (Sandbox Code Playgroud)
完整的工作代码:
<Autocomplete
options={top100Films}
getOptionLabel={(option) => option.title}
style={{ width: 300 }}
renderInput={(params) => (
<TextField
{...params}
InputProps={{ ...params.InputProps, disableUnderline: true }}
label="Combo box"
/>
)}
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4125 次 |
| 最近记录: |