【问题标题】:Facing problem while running Electron+React Application运行 Electron+React 应用程序时遇到问题
【发布时间】:2023-04-07 08:14:01
【问题描述】:

我创建了 Electron+ React 桌面应用程序。当我尝试使用 "index.html" 加载时遇到问题,因为它正在加载 strong> 简单的 js 而不是 jsx(反应代码)。请指导我完成这个。

这是在 Main.js 中

mainWindow.loadURL(file://${path.join(__dirname,'../build/index.html')});

这是我的 index.html 加载 index.js 有反应代码

要求(“../src/index.html”)

谢谢

【问题讨论】:

  • 请提供一些代码来显示您正在尝试做的事情
  • 这个很不清楚。你写什么代码遇到了什么问题?

标签: reactjs electron


【解决方案1】:

尝试改用url.formatHere is the link to the documentation.

类似的东西。

    mainWindow.loadURL(isDev
    ? url.format({
        pathname: path.join(__dirname, '../build/index.html'),
        protocol: 'file:',
      }),
    : url.format({
        pathname: path.join(__dirname, '../build/index.html'),
        protocol: 'file:',
      })
    );

【讨论】:

  • 路径没有问题,但是我们包含在 index.html 中的 index.js 没有加载反应代码,而只是加载了 js,知道如何解决这个问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-22
  • 2014-04-16
  • 1970-01-01
  • 1970-01-01
  • 2018-03-17
  • 1970-01-01
相关资源
最近更新 更多