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 students = ["张三然","李慧思","赵思然","孙力气","钱流量"]; ReactDOM.render( <ul> { students.map(function(username){ return <li>{username}</li> }) } </ul>,document.getElementById("ulLi") ) </script> </head> <body> <div id="ulLi"></div> </body> </html>
3、实现结果
原文链接:https://www.f2er.com/react/305824.html