有序和无序列表
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<p>有序列表:</p>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<p>无序列表:</p>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
示例1
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>React 实例</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
//定义数组
const shuzu = [1, 2, 3, 4, 5,9,2];
//shuzu.map表示上述数组遍历
//'=>'左边若为两个参数(箭头函数有两个形参),必须得括号括起来;形参和实参一致
const listItems = shuzu.map( s1=>
<li>{s1}</li>
);
//渲染
ReactDOM.render(
<ul>{listItems}</ul>,
document.getElementById('example')
);
</script>
</body>
</html>
Appendix
转自菜鸟教程