标签:div ext doctype browser ret turn component babel title
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>nested components</title>
<script src="build/browser.min.js"></script>
<script src="build/react.js"></script>
<script src="build/react-dom.js"></script>
<script type="text/babel">
var MessageBox = React.createClass({
render: function(){
var submessages = [];
for(var ii=0; ii<10; ii++){
submessages.push(
<Submessage key={‘subMsg‘+ii}/>
);
}
return (
<div>
<h1>你好世界!</h1>
{submessages}
</div>
);
}
});
var Submessage = React.createClass({
render: function(){
return (
<div>
<h3>React很有趣</h3>
<Footer/>
</div>);
}
});
var Footer = React.createClass({
render: function(){
return (
<small>因为我们用代码创造世界</small>
);
}
});
ReactDOM.render(<MessageBox/>,
document.getElementById(‘app‘),
function(){
console.log(‘渲染完成啦‘)
});
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
标签:div ext doctype browser ret turn component babel title
原文地址:http://www.cnblogs.com/codepen2010/p/6850615.html