import React,{ Component } from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import * as serviceWorker from './serviceWorker';
class Focus extends Component{
constructor(props){
super(props);
this.focusFn=this.focusFn.bind(this);
}
focusFn(){
.refs.myInput.focus();
}
render(){
return(
<div>
<input type="text" ref="myInput" />
<br/>
<button onClick={this.focusFn}>点我</button>
</div>
)
}
}
ReactDOM.render(
<div>
<Focus />
</div>,document.getElementById('example')
);
serviceWorker.unregister();