你可以通过使用 this 来获取当前 React 组件,或使用 ref 来获取组件的引用
import React, { Component } from 'react';
class App extends Component {
getFocus(){
this.refs.inp.focus();
}
render() {
return (
);
}
}
export default App;