<script type="text/babel">
var Myelement=React.createClass({ handleClick:function(){ this.refs.myInput.focus(); this.refs.[refname]获取真实的节点 只有真实的DOM发生click事件之后 才会发生this.refs.myInput }, render:function(){ return ( <div> <input type="text" ref="myInput" /> <input type="button" value="focus" οnclick={this.handleClick} /> </div> ); } }); ReactDOM.render( <Myelement/>, document.getElementById('example') ); </script>Myelement组件是封装起来,具有获取真实DOM节点功能的组件