如何使用 MUI 组件创建项目符号列表?我尝试添加sx={{listStyleType:'disc'}}到列表组件,但没有成功。这是我的代码:
<List sx={{ listStyleType: 'disc' }}>
<ListSubheader sx={{
fontWeight: 700, lineHeight: '24px', fontSize: '16px', color: 'black'
}}
>
Search Help
</ListSubheader>
<ListItem>Double check your spelling</ListItem>
<ListItem>Your search may have been removed or is not yet in the system</ListItem>
</List>Run Code Online (Sandbox Code Playgroud)
我有一个对象数组,这些对象在 Material UI 自动完成中使用,并通过“getOptionLabel”显示为选项。有没有办法通过将输入字符串与未显示为标签的选项值的属性进行匹配来过滤选项?例如,在下面的示例代码片段中,我希望用户能够键入项目 ID - 例如 5141,并且选项应过滤为“黄铜管”。
const MyAutoComplete = () => {
const [item, setItem] = useState()
const [input, setInput] = useState('')
const items = [
{ id: 5141, name: 'brass pipes', listPrice: 2.32 },
{ id: 214, name: 'bronze pipes', listPrice: 1.89 },
{ id: 3155, name: 'toilet seat ', listPrice: 5.61 }
]
return (
<Autocomplete
options={items}
getOptionLabel={(item) => item.name || ''}
value={item}
onInputChange={(e, v) => {
setInput(v)
}}
isOptionEqualToValue={(option, value) => option.id === value.id}
inputValue={input} …Run Code Online (Sandbox Code Playgroud)