zoukankan      html  css  js  c++  java
  • react.js 测试

    <html>
        <head>
            <title>hellow</title>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
            <meta charset="utf-8"  />
        </head>
        <body>
            <div id="root">

            </div>

            <script type="text/jsx">
            //创建组建
            var TestButtonComponent = React.createClass({
                handleClick:function(event){
                    var tipsE = React.findDOMNode(this.refs.tips);
                    if(tipsE.style.display === 'none'){
                        tipsE.style.display = 'inline';
                    }else{
                        tipsE.style.display = 'none';
                    }
                    event.stopPropagation();    //阻止事件冒泡
                    event.preventDefault();     //阻止默认事件
                },
                render:function(){
                    return (
                            <div>
                                <button onClick={this.handleClick}>显示|隐藏</button><span ref="tips">测试button</span>
                            </div>);
                }
            });

            var TestInputComponent = React.createClass({
                getInitialState:function(){
                    return {
                        inputContent:'ii'
                    };
                },
                handleChange:function(event){
                    this.setState({
                        inputContent:event.target.value
                    });
                },
                render:function(){
                    return (
                        <div>
                            <input type="text" onChange={this.handleChange} /> <span>{this.state.inputContent}</span>
                        </div>
                    );
                }
            });

            //调用组建
            React.render(
                <div>
                    <TestButtonComponent />
                    <br/> <br/>
                    <br/>
                    <TestInputComponent />
                </div>,
                document.getElementById('root')
            );

            </script>
        </body>

    <html>

  • 相关阅读:
    Python单元测试unittest加载方式之二:加载测试套件
    Python单元测试unittest加载方式之二:加载测试套件
    Python单元测试unittest加载方式之一:unittestmain()启动单元测试模块
    和优秀的人相处
    耐心和恒心
    ubuntu下FTP文件目录共享
    一个不错的编译调试方法
    qt 程序异常崩溃
    minigui SetTimer(hwnd, id, speed)
    minigui 按钮点击弹窗外部 弹窗消失功能 WS_EX_TRANSPARENT
  • 原文地址:https://www.cnblogs.com/yuwensong/p/6682924.html
Copyright © 2011-2022 走看看