1、问题背景
2、实现源码
<!DOCTYPE html> <html> <head> <Meta charset="UTF-8"> <title>React获取DOM节点</title> <script type="text/javascript" src="../js/react.js" ></script> <script type="text/javascript" src="../js/react-dom.js" ></script> <script type="text/javascript" src="../js/browser.min.js" ></script> <script type="text/babel"> var Cat = React.createClass({ cutClick:function(){ this.refs.person.focus(); },render:function(){ return ( <div> <input type="text" ref="person" /> <input type="button" value="查询" onclick="{this.cutClick}" /> </div> ) } }); ReactDOM.render( <Cat />,document.getElementById("catQuery") ); </script> </head> <body> <div id="catQuery"></div> </body> </html>
3、实现结果
原文链接:https://www.f2er.com/react/305810.html