小编goo*_*ler的帖子

如何在本机反应中按下按钮时打开键盘?

我有一个按钮,当按下它时,我希望它打开键盘并专注于文本输入组件。

对于一个最小的代码示例,我想做的是 -

      <View>
          <AddSomething
            textChange={textInput => this.setState({ textInput })}
            addNewItem={this.addItem.bind(this)}
            textInput={this.state.textInput}
            ref={not sure what goes here} //passing these as props to a text input
          />
          <FloatingButton tapToAddHandler={this.onFloatingButtonPress.bind(this)} />
      </View>
Run Code Online (Sandbox Code Playgroud)

然后是一些处理按钮按下的辅助函数(this.onFloatingButtonPress)

react-native expo

3
推荐指数
1
解决办法
8550
查看次数

标签 统计

expo ×1

react-native ×1