如何将焦点设置为materialUI TextField? [英] How to set focus to a materialUI TextField?
本文介绍了如何将焦点设置为materialUI TextField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将焦点放在material-ui TextField
组件上?
How can I set the focus on a material-ui TextField
component?
componentDidMount() {
ReactDom.findDomNode(this.refs.myControl).focus()
}
我已经尝试了上面的代码,但是它不起作用:(
I have tried above code, but it does not work :(
推荐答案
您可以使用autoFocus
属性.
<TextField value="some value" autoFocus />
这篇关于如何将焦点设置为materialUI TextField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文