6 回答

TA贡献1827条经验 获得超8个赞
使用 props noOptionsText进行 Material-UI 自动完成
没有选项时显示的文本。出于本地化目的,您可以使用提供的翻译。
参考:Autocomplete API文档
import Autocomplete from '@material-ui/lab/Autocomplete';
<Autocomplete
noOptionsText={'Your Customized No Options Text'}
...
/>

TA贡献1802条经验 获得超6个赞
freeSolo您可以使用条件 on和字段...的组合,noOptionsText如下所示:
<Autocomplete
freeSolo={inputValue?.length ? false : true}
loading={isMatchingUsersLoading}
loadingText={"Searching..."}
options={matchingUsers}
noOptionsText={"No matches..."}
....
/>
这将防止“空框”出现,并且仍然在适当的时间为您提供noOptionsText和文本。loading

TA贡献1884条经验 获得超4个赞
你可以使用 noOption :
<Asynchronous
noOption={ <div className="d-flex align-items-center justify-content-between mt-2">
<span className="fw-bold">User not found?</span>
<Button variant="text" color="primary" type="button" startIcon={<AddIc fontSize="small"/>} onClick={()=>setOpenModal(true)}>Add
User</Button>
</div>}
/>

TA贡献1744条经验 获得超4个赞
const theme = createTheme(
{
components: {
MuiAutocomplete: {
defaultProps: {
noOptionsText: 'any text you want',
},
},
},
}
);
- 6 回答
- 0 关注
- 146 浏览
添加回答
举报