7

我有一个 react 组件在 react 中管理整个应用程序。看起来像:

var Page = React.createClass({
    displayName: 'Page',

    render: function() {
        return (
            React.DOM.div(null
                /*, stuff here ..*/
            )
        );
    }
});

和 html 看起来像

<body id="content"></body>

我把它渲染成:

React.renderComponent(Page(null), document.getElementById('content'));

但相反,我想对整个body标签做出反应,因此没有多余的嵌套div. 我怎样才能渲染这样的东西?

4

1 回答 1

17

我不完全确定这是否是您要问的,但是您可以运行

React.renderComponent(Page(null), document.body);

将组件直接安装到主体中。

于 2014-01-13T22:47:18.617 回答