我正在制作一个电子应用程序,但是每次我重新加载它时,我的页面都变成空白-使用Ctrl + R
。开发人员工具也将变为空白,并且显示以下错误-
Devtools was disconnected from the page
Once page is reloaded DevTools will automatically reconnect
这是我的package.json
{
"name": "pla",
"version": "1.0.0",
"description": "T",
"main": "main.js",
"scripts": {
"start": "electron .",
"rebuild": "electron-rebuild -f -w sqlite3"
},
"author": "R",
"license": "MIT",
"dependencies": {
"custom-electron-titlebar": "^3.2.4",
"electron": "^10.1.3",
"jquery": "^3.5.1",
"knex": "^0.21.6",
"sqlite3": "^5.0.0"
},
"devDependencies": {
"electron-rebuild": "^2.2.0"
}
}
初始化devtools
// Add developer tools item if not in production
if (process.env.NODE_ENV != "production") {
mainMenuTemplate.push({
label: "Developer Tools",
submenu: [
{
label: "Toggle Devtools",
accelerator: process.platform == "darwin" ? "command+I" : "Ctrl+I",
click(item, focusedWindow) {
focusedWindow.toggleDevTools();
},
},
{
role: "reload",
},
],
});
}