Skip to content

插槽

jsx
class Parent extends Component {
    render(){
        return <Child> 插槽数据 </Child>
    }
}
  • this.props.children 获取
jsx
class Child extends Component {
    render(){
        return <div> {this.props.children} </div>
    }
}

函数式

jsx
function Child({ children }) {
    return <div> {children} </div>
}