使用此样板作为参考,我创建了一个Electron应用程序。它使用webpack捆绑脚本并通过Express Server托管脚本。
的WebPack配置是实质上相同的这个和服务器这样。
Electron的脚本加载:
mainWindow.loadURL('file://' + __dirname + '/app/index.html');
然后index.html加载服务器托管的脚本:
<script src="http://localhost:3000/dist/bundle.js"></script>
我运行electron index.js以构建应用程序并node server启动服务器,该服务器使用webpack将脚本捆绑在一起。
electron index.js
node server
它工作正常,我的React组件App已安装。但是我如何将react-router集成到其中呢?
我以与在浏览器应用程序中相同的方式来实现它。我收到此错误:
[react-router] Location "/Users/arjun/Documents/Github/electron- app/app/index.html" did not match any routes
它以文件路径作为路由。浏览样板代码没有帮助。我想念什么?
另一种选择是改为使用 hashHistory 。实际上,在您所引用的 仓库中 ,您可以看到他们正在使用 hashHistory ,然后尝试并回发该怎么样?