【问题标题】:How to get TextInput current cursor position in React Native如何在 React Native 中获取 TextInput 当前光标位置
【发布时间】:2021-11-10 22:28:21
【问题描述】:

有什么方法可以在 react native 中获取 textinput 的光标位置?我想要实现的是我有一个文本输入并在其上输入“#”,它将显示光标当前位置上方的选项列表。

类似于这张图片

【问题讨论】:

标签: react-native tags textinput react-native-textinput


【解决方案1】:

您可以为此使用onSelectionChange:

<Input
  ...
  onSelectionChange={(e) => console.log(e.nativeEvent.selection)}
/>

【讨论】:

    猜你喜欢
    • 2016-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-16
    • 2011-09-19
    • 1970-01-01
    • 2021-11-30
    相关资源
    最近更新 更多