<分区>
我正在尝试使用 play 框架创建一个 web 应用程序,我想在前端使用 react js。如何将 React js 集成到我的 play web 应用程序中?
<分区>
我正在尝试使用 play 框架创建一个 web 应用程序,我想在前端使用 react js。如何将 React js 集成到我的 play web 应用程序中?
最佳答案
我对游戏框架的了解为零,但将 React 集成到您的 Web 应用程序中并不难。
如果你编译过reactjs JS文件。只需包含在索引页的 header 标记中。并用 ID 声明 div。然后做一些这样的代码
html
<div id="root">
<!-- This element's contents will be replaced with your component. -->
</div>
react
ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('root')
);
演示:http://codepen.io/gaearon/pen/rrpgNB?editors=1010
这篇博客文章可能有助于解决您的问题 https://facebook.github.io/react/docs/rendering-elements.html
关于javascript - 如何在 play web 应用程序中集成 react js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43836850/