【发布时间】:2021-07-21 10:20:54
【问题描述】:
我的 react web 应用程序在开发模式下运行良好,当我从 express 服务器托管构建版本时它也运行良好。但是当我尝试从电子 js 渲染它时,它不会渲染任何东西。
在控制台中,它显示 Failed to load resource: net::ERR_FILE_NOT_FOUND main.8d9a4060.chunk.css:1 Failed to load resource: net::ERR_FILE_NOT_FOUND,我无法理解是什么导致了问题。
我的电子密码是这样的:-
const { app, BrowserWindow } = require('electron');
const path = require('path');
if (require('electron-squirrel-startup')) {
app.quit();
}
const createWindow = () => {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
});
mainWindow.loadFile(path.join(__dirname, 'build', 'index.html'));
mainWindow.webContents.openDevTools();
};
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
【问题讨论】:
-
如何启动 React 和 electron? (你的
start脚本是什么)?尝试关注此guide
标签: javascript reactjs rxjs electron electron-builder