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.

33 lines
868 B

2 years ago
  1. import React from 'react'
  2. // children 要在调试工具才能查看
  3. function ListItem ({ children }) {
  4. // children()
  5. return (
  6. // <div>ListItem,{children}</div>
  7. <div>{children.map(child => child)}</div>
  8. )
  9. }
  10. class App extends React.Component {
  11. render () {
  12. return (
  13. <ListItem>
  14. {/* 这里的 children 是 div */}
  15. {/* <div>this is children</div> */}
  16. {/* 这里的 children 是一个函数,可以调用 */}
  17. {/* {() => console.log(123)} */}
  18. {/* 这里的 children 是一个 jsx */}
  19. {/* {<div><p>{'this is p'}</p></div>} */}
  20. {/* 这里的 children 是一个数组 */}
  21. <div>this is div</div>
  22. <p>this is p</p>
  23. </ListItem>
  24. )
  25. }
  26. }
  27. export default App