当 Select isSearchable 时,我希望键盘处于数字模式

When Select isSearchable i would like the keyboard to be in number mode

当 Select 可搜索且设备是移动设备时,我希望键盘处于数字模式。这可能吗?谢谢

您必须使用 components framework 覆盖 Input 组件并将 pattern 属性设置为仅在当前设备为移动设备时才允许数字。

输入元素上的 pattern 属性(或属性)检查输入值以进行输入验证。通过正确的模式,它可以控制您在移动设备上获得的键盘类型。 \d* 是一个正则表达式模式,只允许输入数字。

const Input = (props) => <components.Input {...props} pattern={somehowCheckForMobile() ? "\d*" : undefined} />;

<Select 
    { ... }
    components={{
        Input
    }}
/>

CodeSandbox example