React Native Windows 中 TextInput 无法获取焦点怎么办?
我在用 React Native for Windows 开发桌面应用,发现点击 TextInput 组件时根本没法聚焦输入,光标都不出现。试过加 autoFocus 也没用,Windows 上是不是要额外配置什么?
组件代码很简单,就是:
const MyInput = () => {
return <TextInput style={{ borderWidth: 1, padding: 8 }} />;
};
在 iOS 和 Android 上都正常,就 Windows 不行,有遇到过类似问题的吗?
pre class="pure-highlightjs line-numbers">
import React, { useRef } from 'react';
inputRef.current.focus()}>
import { TextInput, View } from 'react-native';
const MyInput = () => {
const inputRef = useRef(null);
return (
);
};
export default MyInput;
复制过去试试,应该能解决焦点问题。