React(0.13) 동적 구성 요소 정의(동적 값으로 함수)

1925 단어
<!DOCTYPE html>
<html>
    <head>
        <title>React JS</title>
        <script src="../build_0.13/react.js"></script>
        <script src="../build_0.13/JSXTransformer.js"></script>
        <script>
            function dateToString(d){
                return [d.getFullYear(), d.getMonth()+1, d.getDate()].join('-');
            }
        </script>
    </head>
    <body>
        <div id="example"> </div>
        <script type="text/jsx">
            var h1 = "question";
            var Divider = React.createClass({
                    render:function(){
                        return (<div className="divider">
                                    <h1>{dateToString(new Date())}</h1>
                                </div>
                                );
                    }
                });
            
            // 
            React.render( <Divider />, document.getElementById('example') );
            
            
        </script>
    </body>
</html>

좋은 웹페이지 즐겨찾기