【问题标题】:Routing Reactjs in Electron app在 Electron 应用中路由 Reactjs
【发布时间】:2016-03-03 07:38:32
【问题描述】:

我创建了 Electron 应用程序,浏览器还可以,但是 Electron 环境不同意路由路由。附件一中送全屏。请指教。

【问题讨论】:

  • 那是什么版本的 react-router?我在 2.0.1 上遇到了同样的问题。我绕过它的方法是使用哈希历史。无论如何,您都没有针对任何 SEO 工具。
  • 你能解决这个问题吗?我也遇到了这个问题,下面给出的解决方案不起作用。

标签: reactjs routing electron


【解决方案1】:

我发现做到这一点的最佳方法是使用path.join,您知道这真的很有帮助吗?

# IMPORT PATH ES6/7

# es6: const path = require('path');

# CONSTRUCT YOUR BUILD PATH
const build_path = path.join(__dirname), '/build');

# mainWindow.loadURL('file://' + build_path + '/index.html')

console.log('file://' + build_path + '/index.html');
# -> file://build/index.html

【讨论】:

    猜你喜欢
    • 2021-04-22
    • 1970-01-01
    • 2016-08-20
    • 2018-08-07
    • 1970-01-01
    • 2016-04-18
    • 1970-01-01
    • 2017-09-28
    • 2019-09-26
    相关资源
    最近更新 更多