如何将textarea焦点设置在react-native webview中

时间:2018-03-14 09:15:34

标签: javascript html react-native

我想在react-native webview中设置textarea autoFoucs,但它不起作用?有人知道如何解决它吗?请联系我,谢谢!

<WebView
ref={ref => this.webView = ref}
automaticallyAdjustContentInsets={false}
style={{ width: this.mScreenWidth, flex: 1, backgroundColor: '#fff', marginTop: this._getSize(5), paddingHorizontal: this._getSize(16), paddingTop: this._getSize(5) }}
source={{ uri: 'http://localhost:8081/richEditor/richEditor.html' }}
javaScriptEnabled={true}
dataDetectorTypes='none'
startInLoadingState={true}
scrollEnabled={true} />

<textarea id="textarea" autofocus="autofocus"></textarea> <script type="text/javascript" charset="utf-8"> document.getElementById("textarea").focus(); </script>

1 个答案:

答案 0 :(得分:0)

将autoFocus与input元素一起使用

   <input autoFocus />