React 中textarea自动聚焦
时间:2020-05-11 18:33:12
收藏:0
阅读:225
<textarea
ref={(textarea)=> this.textarea = textarea}
value={this.state.content}
onChange={this.handleContentChange.bind(this)} />
componentDidMount() {
this.textarea.focus();
}
原理是获取textarea的DOM元素(通过ref),调用focus() API就可以了!
this.textarea.focus();
}
原理是获取textarea的DOM元素(通过ref),调用focus() API就可以了!
原文:https://www.cnblogs.com/xingzoudecd/p/12870372.html
评论(0)