之前写的更多的时候是直接使用简写 {props.children} 这样就可以了,但是当有时候需要对传入的子组件进行一些操作的时候需要用到React.Children方法

{React.Children.map(children, (child, i) => {
     // 将传入的第一个子组件隐藏
if (i < 1) return return child })}

 

相关文章:

  • 2022-12-23
  • 2021-06-19
  • 2021-04-13
  • 2022-02-24
  • 2021-12-20
  • 2021-05-19
  • 2022-01-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-03
  • 2021-10-29
  • 2021-12-27
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案