电子不渲染反应路线

时间:2019-08-04 15:25:02

标签: reactjs electron

我已经创建了一个reactjs网页,现在我正在尝试在电子应用中实现它。在开发过程中没有问题,但是在我构建应用程序时,没有任何路线得到渲染,也没有出现任何错误。

这是我的app.js文件:

<HashRouter basename="/">
  <div id="title-bar" className="d-flex justify-content-between">
    <div id="title" className="d-flex align-items-center">
      <span className="line-height-1 f-s-12 f-w-4 pl-10">
        {this.state.pageTitle}
      </span>
    </div>
    <div id="title-bar-btns">
      <button id="min-btn" className="text-color-white">
        -
      </button>
      <button id="max-btn" className="text-color-white">
        +
      </button>
      <button id="close-btn" className="text-color-white">
        x
      </button>
    </div>
  </div>

  <Route
    exact
    path={`${process.env.PUBLIC_URL}/`}
    render={(props: any) => <Navbar {...props} />}
  />

  <Route
    exact
    path={`${process.env.PUBLIC_URL}/`}
    render={(props: any) => (
      <Header {...props} title={this.state.pageTitle} />
    )}
  />

  {/* ... */}
</HashRouter>
div中的

HashRouter获得渲染,其他所有内容都没有得到。

这是我的electron.js文件:

const electron = require("electron");
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

const path = require("path");
const isDev = require("electron-is-dev");

let mainWindow;

function createWindow() {
    mainWindow = new BrowserWindow({
        width: 1280,
        height: 720,
        "min-width": 1280,
        "min-height": 720,
        // frame: false,
        webPreferences: {
            nodeIntegration: true
        }
    });
    // mainWindow.removeMenu();
    mainWindow.loadURL(
        isDev
            ? "http://localhost:3000"
            : `file://${path.join(__dirname, "../build/index.html")}`
    );

    mainWindow.on("closed", () => (mainWindow = null));
}

app.on("ready", createWindow);

app.on("window-all-closed", () => {
    if (process.platform !== "darwin") {
        app.quit();
    }
});

app.on("activate", () => {
    if (mainWindow === null) {
        createWindow();
    }
});

0 个答案:

没有答案
相关问题