【问题标题】:How to set textarea focus in react-native webview如何在 react-native webview 中设置 textarea 焦点
【发布时间】:2018-08-22 17:49:21
【问题描述】:

我想在 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.人们不应该联系你——这是一个论坛,它的运作方式是问题应该公开解决,这样其他人也会从中受益。 2. 您应该发布您的代码 - 您尝试过哪些不起作用的方法?
  • 首先,感谢您的建议。我再次编辑问题,请再次检查,谢谢。

标签: javascript html react-native


【解决方案1】:

对输入元素使用自动对焦

   <input autoFocus />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-13
    • 2018-01-27
    • 1970-01-01
    • 2020-07-11
    • 2019-10-22
    • 2021-11-26
    • 2018-02-24
    相关资源
    最近更新 更多