我正在為 React 編寫練習(xí)代碼,但我停止了,因?yàn)槲冶仨氃谄渌撁嬷g共享導(dǎo)航欄我找到了下一個解決方案并且它有效,但我不知道具體是如何工作的;這是一個課程項目。function Layout(props) { return( <React.Fragment> <Navbar /> {props.children} </React.Fragment> );}我真的{props.children}不知道真正做什么以及如果 Layout 組件開始持有其他組件 Navbar 組件仍然出現(xiàn)<Layout> <Switch> <Route exact path="/badges" component={Badges}/> <Route exact path="/badges/new" component={BadgeNew} /> </Switch></Layout>幕后發(fā)生了什么?
“props.children” 如何在 React 組件上工作?
一只萌萌小番薯
2021-08-20 10:21:10