是否可以有一个下拉字段,但能够添加下拉菜单建议的值以外的值?
类似于将showAllItems 设置为 true 且没有自动完成功能的自动完成字段
编辑:
我想要实现的只是提交带有自定义值的表单或从下拉列表中选择用户(根据用户的选择)
是否可以有一个下拉字段,但能够添加下拉菜单建议的值以外的值?
类似于将showAllItems 设置为 true 且没有自动完成功能的自动完成字段
编辑:
我想要实现的只是提交带有自定义值的表单或从下拉列表中选择用户(根据用户的选择)
使用onNewRequest
属性。根据https://github.com/callemall/material-ui/blob/master/src/auto-complete.jsx:
const AutoComplete = React.createClass({
...
render() {
...
return (
<div style={mergedRootStyles} onKeyDown={this._handleKeyDown}>
<div style={{width: '100%',}}>
<TextField
{...other}
ref="searchTextField"
value={this.state.searchText}
onEnterKeyDown={() => {
setTimeout(() => {
this._close();
}, this.props.touchTapCloseDelay);
this.props.onNewRequest(this.state.searchText);
}}
...
每次用户按下时都会调用使用此属性传递的函数Enter
,因此您可以在该函数内部处理提交输入。
使用 mui 自动完成功能,您走在了正确的轨道上。尝试使用该freeSolo
选项