react通過父組件渲染子組件中的內容
阿新 • • 發佈:2018-05-04
react通過父組件渲染子組件中的內容說明:
代碼:
效果:
// less require (‘./static/less/index.less‘) // 核心 var React = require(‘react‘) var ReactDom = require(‘react-dom‘) var ReactRouter = require(‘react-router-dom‘) var Router = ReactRouter.BrowserRouter var Route = ReactRouter.Route var Link = ReactRouter.Link var CreateClass = require(‘create-react-class‘) var PropTypes = require(‘prop-types‘) var Ajax = require(‘dollarphp-ajax‘) // 創建組件 var Index = CreateClass({ render:function(){ return ( <Head> <div> hello world </div> </Head> ) } }) var Head = CreateClass({ render:function(){ return ( <div> {this.props.children} </div> ) } }) // 渲染 ReactDom.render( <Index/>, document.getElementById(‘app‘) )
react通過父組件渲染子組件中的內容