reactjs - 无法在 aoutoComplete 材质 UI 中读取 null 的属性“selectionEnd”
问题描述
我对自动完成有问题,反应文本掩码是这样的:
<MaskedInput
{...other}
ref={ref => {
inputRef(ref ? ref.inputElement : null);
return ref;
}}
mask={[
/\d/,
/\d/,
/\d/,
/\d/,
' ',
/\d/,
/\d/,
/\d/,
' ',
/\d/,
/\d/,
/\d/,
/\d/,
]}
placeholderChar={'\u2000'}
/>;
自动完成组件是这样的:
<AmountAutoComplete
options={this.state.autoCompleteOptions.map(option => option.title)}
renderInput={params => {
return (
<TextField
value={this.props.value}
onChange={e => {
onValueChange(e.currentTarget.value, '');
}}
InputProps={{
inputComponent: this.TextMaskCustom,
}}
/>
);
}}
/>;
错误是
无法在 handleClick 处读取 null 的属性“selectionEnd”(useAutocomplete.js:763)
并且在 useAutocomplete.js:763 中有关于 inputRef 的错误:
var handleClick = function handleClick() { if (firstFocus.current && inputRef.current.selectionEnd - inputRef.current.selectionStart === 0) { inputRef.current.focus(); inputRef.current.select(); }
解决方案
我应该像这样将参数发送到 textField :
<TextField
{...params}
InputProps={{
...params.InputProps,
}}
/>
推荐阅读
- python - python中带有re.search的正则表达式不起作用
- python-3.x - How to set LANG when creating a bundle with PyInstaller
- ruby-on-rails - 使用特定时区解析 DateTime
- php - 从视图中何处获取路线的第二个参数?
- typescript - TypeScript 类通用参数约束
- jsf - 当 ManagedBean 封装在 JAR 中并由 EAR 提供时,JSF @PostConstruct 不会触发
- python - Python Sunburst Chart - 将数据框转换为嵌套列表格式
- azure - Dynamics 365:是否需要为所有应用提供服务条款和隐私声明链接?
- android - 与项目中的依赖项“com.android.support:support-annotations”冲突
- python - Python中的TypeError,用于查找基于第二个元素的最大值的元组列表