我的應用程序是一個瀏覽器窗口加載本地頁面index.html電子。
我打電話給「npm run start」腳本運行「electron main.js」,應用程序打開並載入html。
我可以添加一個參數給腳本,將不同的html文件加載到BrowserWindow中?如何使用參數運行電子應用程序?
在main.js文件中的代碼是:
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
webPreferences:{
webSecurity:false
},
fullscreen : false });//, alwaysOnTop : true , kiosk : true })
mainWindow.setMenu(null);
// and load the index.html of the app.
let url = `file://${__dirname}/index.html`; \\ index.html should be determined by argument passed at start.
mainWindow.loadURL(url,loadOptions);
// 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;
});
}
是'process.argv'不填充? –
是的,但我如何傳遞我的參數,如-html = index2.html –