【发布时间】:2018-12-16 20:13:51
【问题描述】:
这种情况:我的主页有index.html。我不使用 React。但是在主页上有一个我使用 React 的游戏页面上的链接。
我需要在游戏页面上创建应用程序,但 webpack(我认为)只能在 index.html. 上渲染应用程序我在游戏页面上有渲染容器。但反应忽略它。另一方面,当我在主页上为 rander 创建容器时,一切正常。
代码和平:
import React from 'react';
import ReactDOM from 'react-dom';
import ElectronApp from './components/ElectronApp';
import {
HashRouter,
Route
} from 'react-router-dom'
ReactDOM.render(
<HashRouter>
<Route path="/electron-game.html" component={ElectronApp} />
</HashRouter>,
document.getElementById('root')
)
我可以做些什么来解决我的问题,我不知道我需要使用路由器。
【问题讨论】:
标签: javascript reactjs