📜  反应创建组件列表 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:21.878000             🧑  作者: Mango

代码示例1
function ListItem(props) {
  // Correct! There is no need to specify the key here:  return 
  • {props.value}
  • ;} function NumberList(props) { const numbers = props.numbers; const listItems = numbers.map((number) => // Correct! Key should be specified inside the array. ); return (
      {listItems}
    ); } const numbers = [1, 2, 3, 4, 5]; ReactDOM.render( , document.getElementById('root') );