0
我想製作electronjs文本編輯器應用程序,我希望能夠使用編輯器內編寫的腳本打開新窗口。例如,我在我的編輯器中有小腳本,當我在瀏覽器中按下打開時,它會打開並加載到瀏覽器窗口中。這是我的代碼的一部分。在electron.js中打開文件
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
});
// and load the index.html of the app.
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true,
})
);
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
// trigger autoupdate check
autoUpdater.checkForUpdates();
}
我在HTML按鈕:
<button id="openBrowser"><img src="img/16x16/diskette.png"/>Open in Browser </button>
哎呀,我犯了一個錯誤,所以我編輯它。我寫了'BrowserWindow',我的意思是'openExternal'。對不起,有任何困惑 –