• 夺命雷公狗-----React---13--事件监听


    在react中事件监听直接作为组建的属性来添加即可,就像DOM中的html操作

    <!DOCTYPE>
    <html>
        <head>
            <meta charset="utf-8">
            <title></title>
            <script src="./js/react.js"></script>
            <script src="./js/react-dom.js"></script>
            <script src="./js/browser.min.js"></script>
            <style>
                *{ margin:0px;  padding:0px;}
                .lists ul{ list-style:none; clear:both; }
                .lists ul li{ clear:; }
                .lists ul li img{ width:100px; }
                .lists ul li div:nth-child(1),.lists ul li div:nth-child(2),.lists ul li button{ float:left; }
                .lists ul li div:nth-child(2),.lists ul li button{ margin-left:30px; }
                .lists ul li button{ line-height:80px; height:80px; }
            </style>
        </head>
        <body>
            <div id="dome"></div>
            <script type="text/babel">
                var Fix = React.createClass({
                    handleClick:function(){
                        alert('别老是点我');
                    },
                    render:function(){
                        return (
                            <div>
                                <h1>事件处理</h1>
                                <button onClick={this.handleClick}>GO</button>
                            </div>
                        );
                    }
                });
                ReactDOM.render(
                    <Fix />,
                    document.getElementById('dome')
                );
            </script>
        </body>
    </html>
  • 相关阅读:
    习题2-7
    习题2-6
    习题2-5
    习题2-4
    习题2-3
    作业二 分支循环结构
    2- 8
    实验三-计算圆柱体积
    实验三-计算n个圆柱体体积
    实验3-计算圆面积
  • 原文地址:https://www.cnblogs.com/leigood/p/6074562.html
Copyright © 2020-2023  润新知