gpt4 book ai didi

javascript - 有没有办法更改 Material ui的自动完成组件上的关闭图标?

转载 作者:行者123 更新时间:2023-12-05 03:43:25 24 4
gpt4 key购买 nike

我想更改图标,但希望保留点击时的功能。有好的解决方案吗?

I want to change this Icon

<Autocomplete
multiple
id="checkboxes-tags-demo"
options={top100Films}
disableCloseOnSelect
getOptionLabel={(option) => option.title}
renderOption={(option, { selected }) => (
<React.Fragment>
<Checkbox
icon={icon}
checkedIcon={checkedIcon}
style={{ marginRight: 8 }}
checked={selected}
/>
{option.title}
</React.Fragment>
)}
style={{ width: 500 }}
renderInput={(params) => (
<TextField {...params} variant="outlined" label="Checkboxes" placeholder="Favorites" />
)}
/>

谁能帮帮我?

最佳答案

您可以通过一个函数来自定义自动完成所使用的 Chip 组件的渲染

<Autocomplete
multiple
id="tags-filled"
options={top100Films.map((option) => option.title)}
defaultValue={[top100Films[13].title]}
freeSolo
renderTags={(value, getTagProps) =>
value.map((option, index) => (
<Chip variant="outlined" label={option} {...getTagProps({ index })} />
))
}
renderInput={(params) => (
<TextField {...params} variant="filled" label="freeSolo" placeholder="Favorites" />
)}
/>

并且可以使用 deleteIcon 属性进一步自定义 Chip 组件

编辑:有关详细信息,请参阅 the API of the Autocompletethe API of the Chip

关于javascript - 有没有办法更改 Material ui的自动完成组件上的关闭图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66855117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com