【问题标题】:How to navigate in electron without opening new windows如何在不打开新窗口的情况下在电子中导航
【发布时间】:2022-08-16 09:02:08
【问题描述】:

我想在同一窗口中的 html 页面之间移动而不在每个导航上打开一个新窗口我如何在电子中做到这一点

    标签: javascript node.js electron desktop-application desktop


    【解决方案1】:

    那么显而易见的答案是在您触发的某个事件上加载不同的 HTML 文件(很可能使用 ipc)

    ipcMain.on("some-event",(event)=>{
     /** */
    let win = BrowserWindow.getFocusedWindow(); // get active window
    win.loadFile("2nd html.html"); // refresh html file
    /** OR */ 
    win.loadURL("remote URL.html") // refresh html file from a remote link
    
    win.reload() // if necessary
    })
    

    确保在加载文件之前使用 ipcRenderer 和 ipcMain 传递所需的任何数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-27
      • 2018-07-04
      • 2017-10-29
      • 2011-05-15
      • 2021-08-22
      • 1970-01-01
      • 2010-12-09
      相关资源
      最近更新 更多