1、问题背景
利用React遍历标签数组,并生成有序列表
2、实现源码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>React遍历标签数组</title>
<script type="text/javascript" src="../js/react.js" ></script>
<script type="text/javascript" src="../js/react-dom.js" ></script>
<script type="text/javascript" src="../js/browser.min.js" ></script>
<script type="text/babel">
var strArray = [
<label>春季</label>,
<span>夏季</span>,
<p>秋季</p>,
<dl>冬季</dl>
];
ReactDOM.render(
<ol>
{
strArray.map(function(username){
return <li>{username}</li>
})
}
</ol>,
document.getElementById("arrDiv")
);
</script>
</head>
<body>
<div id="arrDiv"></div>
</body>
</html>
3、实现结果