You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
572 B

2 years ago
  1. /* react
  2. 技术方案map 重复渲染的是哪个模板就 return
  3. 注意事项遍历列表同时需要一个类型为 number/string 不可重复的 key 提高 diff 性能
  4. key 仅仅在内部使用不会出现在真实的 DOM 结构中
  5. */
  6. const user = [
  7. { id: 1, name: 'ken', age: 20},
  8. { id: 2, name: 'Luckly', age: 30},
  9. { id: 3, name: 'Max', age: 40},
  10. ]
  11. function App() {
  12. return (
  13. <div className="App">
  14. { user.map( user => <li key={user.id}>{ user.name }{user.age}</li>)}
  15. </div>
  16. );
  17. }
  18. export default App;