1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Document</title>
    8. </head>
    9. <body>
    10. <div id="app"></div>
    11. <script src="../js/react.development.js"></script>
    12. <script src="../js/react-dom.development.js"></script>
    13. <script src="../js/babel.min.js"></script>
    14. <script src="../js/prop-types.js"></script>
    15. <script type="text/babel">
    16. class Input extends React.Component{
    17. submitHandle=(e)=>{
    18. const {username,password}=this
    19. e.preventDefault()
    20. alert("我的名字"+username.value+"我的密码"+password.value)
    21. }
    22. render(){
    23. return (
    24. <form action="" onSubmit={this.submitHandle}>
    25. 用户名:<input type="text" placeholder="请输入用户名" name="name" ref={c=>this.username=c}/>
    26. 密码:<input type="password" placeholder="请输入密码" name="password" ref={c=>this.password=c} />
    27. <button >登录</button>
    28. </form>
    29. )
    30. }
    31. }
    32. ReactDOM.render(<Input/>,document.getElementById("app"))
    33. </script>
    34. </body>
    35. </html>

    页面中输入类的dom现用现取就是非控类型的组件