📜  反应列表渲染 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:43.851000             🧑  作者: Mango

代码示例1
function Blog(props) {
  const sidebar = (    
    {props.posts.map((post) =>
  • {post.title}
  • )}
); const content = props.posts.map((post) =>

{post.title}

{post.content}

); return (
{sidebar}
{content}
); } const posts = [ {id: 1, title: 'Hello World', content: 'Welcome to learning React!'}, {id: 2, title: 'Installation', content: 'You can install React from npm.'} ]; ReactDOM.render( , document.getElementById('root') );