热门IT资讯网

react通过父组件渲染子组件中的内容

发表于:2024-11-25 作者:热门IT资讯网编辑
编辑最后更新 2024年11月25日,说明:代码:// lessrequire ('./static/less/index.less')// 核心var React = require('react')var ReactDom = req
  1. 说明:
  2. 代码:
    // lessrequire ('./static/less/index.less')// 核心var React = require('react')var ReactDom = require('react-dom')var ReactRouter = require('react-router-dom')var Router = ReactRouter.BrowserRoutervar Route = ReactRouter.Routevar Link = ReactRouter.Linkvar CreateClass = require('create-react-class')var PropTypes = require('prop-types')var Ajax = require('dollarphp-ajax')// 创建组件var Index = CreateClass({render:function(){    return (                    
    hello world
    )}})var Head = CreateClass({render:function(){ return (
    {this.props.children}
    )}})// 渲染ReactDom.render( , document.getElementById('app'))
  3. 效果:
0