1.因为jsx将两个花括号之间的内容渲染为动态值,只需要引用对应的变量即可
<!DOCTYPE html> <html> <head> <title>React JS</title> <script src="../build_0.13/react.js"></script> <script src="../build_0.13/JSXTransformer.js"></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>{h1}</h1> </div> ); } }); //将组件加到对应的元素上 React.render( <Divider />, document.getElementById('example') ); </script> </body> </html>