您能解释一下,选择代码国家后如何集中输入吗?在演示中它按预期工作,但我的不起作用......
有PhoneInput组件的代码:
<PhoneInput
inputProps={{
autoFocus: true
}}
onChange={(e, action) => phoneChange(e, action)}
localization={i18n.language === 'ru' && ru}
placeholder={placeholder}
value={phoneNumber}
buttonClass={styles.phoneButton}
inputClass={styles.phoneInput}
dropdownClass={styles.phoneDropdown}
searchClass={styles.phoneSearch}
searchPlaceholder={searchHolder}
searchNotFound={searchFind}
country={country}
disableSearchIcon={true}
enableSearch={true}
autocompleteSearch={true}
jumpCursorToEnd={true}
/>
我尝试将 inputProps 传递给 PhoneInput 组件,但它将输入集中在第一个挂载上;(
我想您的项目中安装了最新版本的react-phone-input-2(
2.15.1
或2.15.0
)。
低于
2.14.0
的版本将为您完成这项工作。
您可以卸载当前版本:
npm uninstall react-phone-input-2
并安装
2.14.0
版本,当您更改国家/地区时,可与 autoFocus
配合使用:
npm install [email protected]