私のアプリケーションは、ローカルページindex.htmlをロードするBrowserWindowを持つ電子です。
"electron main.js"を実行するスクリプトを "npm run start"と呼びます。アプリが開き、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 –