美文网首页
2018-08-16 react jsx

2018-08-16 react jsx

作者: aaagu1234 | 来源:发表于2018-08-16 15:25 被阅读4次

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>菜鸟教程 React 实例</title>
<script src="https://cdn.bootcss.com/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.bootcss.com/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.bootcss.com/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>

<div id="example"></div>
<script type="text/babel">
function HelloMessage(props) {
return <h1>Hello 啊!</h1>;
}

function Repeat(props){
var item = [];
for(var i = 0;i<props.numTimes;i++){
item.push(props.children(i,'ha'))
}

return <div>132{item}</div>;
}

function ListOf(){
return (
<Repeat numTimes={10}>
{(index,args)=><div key={index}>{args} this is {index} in the list.</div>}
</Repeat>
);

}

ReactDOM.render(
<ListOf />,
document.getElementById('example')
);
</script>
</body>
</html>

相关文章

网友评论

      本文标题:2018-08-16 react jsx

      本文链接:https://www.haomeiwen.com/subject/nuhobftx.html