如何在React中添加页脚div?

时间:2018-06-28 20:15:19

标签: javascript html reactjs

在我的React Web应用程序中,index.html中的内容如下:

<body>
  <div id="root"></div>
  <script src="index.js"></script>
</body>

在index.js中,我的渲染方法如下:

render(
  <Provider store={store}>
    <Router history={history} routes={routes} />
  </Provider>,
  document.getElementById('root')
)

我希望能够在index.html和index.js中添加页脚div,以便我可以正确设置其样式,并根据根的动态高度将其保留在页面底部。如何实现页脚div?

1 个答案:

答案 0 :(得分:1)

您可以在<div id="footer"></div>下方添加一个额外的div root并单独呈现:

render(<Footer />, document.getElementById('footer'))