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 關注
- 193 瀏覽
添加回答
舉報