【发布时间】:2020-01-25 07:32:51
【问题描述】:
我正在使用电子 6.10.0 并使用 React.js。
在我的应用程序中,菜单中有一个添加任务选项,它会创建一个新窗口。
在开发过程中一切正常,但在生产过程中,这条线会出现问题。
addWindow.loadURL(isDev ? 'http://localhost:3000/add' : `file://${path.join(__dirname, '../build/index.html')}`);
它加载 index.html,通过它加载 index.js 并渲染 router.js。这是Router.js中的代码。
<HashRouter>
<Switch>
<Route exact path="/" component={App} />
<Route exact path="/add" component={addWindow} />
</Switch>
</HashRouter>
主窗口工作正常,因为哈希是“/”,但对于添加窗口,哈希不会改变,它会在 addwindow 中再次加载主窗口内容。
在生产过程中如何使用路由/Router,或者有没有其他方法。
提前致谢。
【问题讨论】:
标签: javascript reactjs electron electron-builder