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.
|
|
import React from 'react'
// children 要在调试工具才能查看
function ListItem ({ children }) { // children()
return ( // <div>ListItem,{children}</div>
<div>{children.map(child => child)}</div> ) }
class App extends React.Component { render () { return ( <ListItem> {/* 这里的 children 是 div */} {/* <div>this is children</div> */}
{/* 这里的 children 是一个函数,可以调用 */} {/* {() => console.log(123)} */}
{/* 这里的 children 是一个 jsx */} {/* {<div><p>{'this is p'}</p></div>} */}
{/* 这里的 children 是一个数组 */} <div>this is div</div> <p>this is p</p> </ListItem> ) } }
export default App
|