Vue.js 如何在electronvue中实现窗口的前台化
我想在倒计时结束后将主Vue.js 如何在electronvue中实现窗口的前台化,vue.js,electron,electron-vue,Vue.js,Electron,Electron Vue,我想在倒计时结束后将主浏览器窗口带到前台。在App.vue中调用electron.BrowserWindow.getFocusedWindow().show()时,我发现了错误 Uncaught TypeError: Cannot read property 'getFocusedWindow' of undefined electron正在通过const-electron=window.require(“electron”)导入在App.vue中为了避免在渲染器进程中同时执行此部分,同时以更
浏览器窗口
带到前台。在App.vue
中调用electron.BrowserWindow.getFocusedWindow().show()
时,我发现了错误
Uncaught TypeError: Cannot read property 'getFocusedWindow' of undefined
electron
正在通过const-electron=window.require(“electron”)导入
在App.vue中为了避免在渲染器进程中同时执行此部分,同时以更干净的方式执行此部分,您可以尝试将调用getFocusedWidow().show()移动到电子端。
通过这样做:
App.vue
let ipcRenderer = window.require("electron").ipcRenderer
ipcRenderer.send("bring-to-foreground");
electron.js
ipcMain.on("bring-to-foreground", (e) => {
electron.BrowserWindow.getFocusedWindow().show();
}
我还认为您应该使用keep-your-main窗口,这样您就不会使用getFocusedWindow,因为根据文档,如果窗口一开始没有聚焦,它可能会返回null。像这样:
let mainWindow;
const createWindow = () => {
mainWindow = new BrowserWindow({...})
//rest of the function goes here
}
因此,您可以简单地执行以下操作:
mainwindow.show()
您是否尝试过将nodeIntegration设置为true,如下面的示例@mazensharkaway中所示,我已经这样做了