Reactjs 如何自动对焦文本区域?
我已经尝试过自动对焦或对焦(),但似乎不起作用Reactjs 如何自动对焦文本区域?,reactjs,textarea,Reactjs,Textarea,我已经尝试过自动对焦或对焦(),但似乎不起作用 <textarea autoFocus /> or <textarea ref="textarea" /> componentDidMount() { findDOMNode(this.refs.textarea).focus(); } 或 componentDidMount(){ findDOMNode(this.refs.textarea).focus(); } 编辑 autoFocus在chrome中似乎
<textarea autoFocus />
or
<textarea ref="textarea" />
componentDidMount() {
findDOMNode(this.refs.textarea).focus();
}
或
componentDidMount(){
findDOMNode(this.refs.textarea).focus();
}
编辑
autoFocus
在chrome中似乎可以工作
两个autoFocus
foucs()
在iOS中都不起作用 在componentDidMount
中调用focus()
似乎在桌面Chrome和Firefox中都能正常工作
似乎有很多元素。使sur不使用