简体   繁体   English

Electron 开发工具不显示

[英]Electron dev tools don't show

Whenever I start my Electron app & tell it to open the dev tools, nothing happens.每当我启动我的 Electron 应用程序并告诉它打开开发工具时,什么都没有发生。 Manual selection from the menu doesn't do anything, nor does [Ctrl] + [Shift] + I. All the other posts I've seen say to call openDevTools() or use the keyboard shortcut - both of which I'm doing to no avail.从菜单中手动选择没有任何作用,[Ctrl] + [Shift] + I 也没有。我看到的所有其他帖子都说调用openDevTools()或使用键盘快捷键 - 我正在做这两个无济于事。

Here is my window initialization code:这是我的 window 初始化代码:

const Window = new BrowserWindow({
    width: 1200,
    height: 800,
    webPreferences: {
        preload: path.join(__dirname, "..", "preload.js"),
    },
});
Window.webContents.openDevTools();
Window.loadFile(path.join(__dirname, "../..", "index.html"));

I'm using Electron 20.01 on Windows 10.我在 Windows 10 上使用 Electron 20.01。

Edit Further up in my file I'm connecting to an sqlite3 database using Sequelize.在我的文件中进一步编辑我正在使用 Sequelize 连接到 sqlite3 数据库。 It would appear that that code is somehow preventing the dev tools from opening.看起来代码以某种方式阻止了开发工具的打开。

This code:这段代码:

const sequelize = new Sequelize({
    dialect: "sqlite",
    storage: path.join(__dirname, "..", "..", "db.db"),
});

Is the culprit.是罪魁祸首。 Commenting it out results in the dev tools showing.将其注释掉会导致开发工具显示。

I believe the webContents of the window is only initialized once you navigate the window to a page, so you should open the devtools only after you've done that, preferably after awaiting the load.我相信webContents的 webContents 仅在您将 window 导航到页面后才被初始化,因此您应该仅在完成后打开开发工具,最好是在等待加载之后。

await Window.loadFile(path.join(__dirname, "../..", "index.html"));
Window.webContents.openDevTools();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM