<textarea
       ref={(textarea)=> this.textarea = textarea}
       value={this.state.content}
       onChange={this.handleContentChange.bind(this)} />

componentDidMount() {
    this.textarea.focus();
}
原理是获取textarea的DOM元素(通过ref),调用focus() API就可以了!

相关文章:

  • 2021-12-27
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案