react 本身自带类似与vue的slot功能(具名插槽)

2021-02-13  本文已影响0人  Small_Song
class Layout extends Component {
    render(){
        return (
            <div>
                <h1>{this.props.head}</h1>
                <h2>{this.props.body}</h2>
                <h3>{this.props.foot}</h3>
            </div>
        )
    } 
}
<Layout head={<Header />} body={<Body />} foot={<Foot />}/>
上一篇 下一篇

猜你喜欢

热点阅读