📜  li key 属性 - Javascript 代码示例

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

代码示例1
//A “key” is a special string attribute you need 
//to include when creating lists of elements.

function NumberList(props) {
  const numbers = props.numbers;
  const listItems = numbers.map((number) =>
    
  • {number}
  • ); return (
      {listItems}
    ); } const numbers = [1, 2, 3, 4, 5]; ReactDOM.render( , document.getElementById('root') );