在组件内部调用内部div - React Js

时间:2017-10-30 06:59:03

标签: reactjs

组件代码:

Class Section extends Component{
   render(){
      return(<div>
              <div className="section">
                <div className="content">
                </div>
               </div>
             </div>  
     )
  }

}

App.js代码

Class App extends Component{
      render(){
        return(
       <Section></Section>
    <!-- here i need to call the inner or child div which is **content** from the component how can i call that one here -->

   )

  }

}

我需要多次调用内容div,如何调用那个

提前致谢

1 个答案:

答案 0 :(得分:0)

这样的事情会解决你的目的吗?

<强> Content.js

FullName_LastNameFirst

<强> Section.js

Class Content extends Component {
  render() {
    return (
      <div className="content">
        {this.props.content}
      </div>
    )
  }
}

<强> App.js

Class Section extends Component{
   render(){
      return(
        <div>
          <div className="section">
            {this.props.children}
          </div>
       </div>  
     )
  }
}