日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

electron 窗口BrowserWindow

發布時間:2024/3/26 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 electron 窗口BrowserWindow 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
const mainWindow = new BrowserWindow({width: 800,height: 600,frame:false, 彈出的窗口有無邊框,默認為有show:false, 是否顯示窗口,否后,通過對象.show()打開backgroundColor:"#ADD6FF" 設置背景色,16進制rgba格式webPreferences: { 網頁功能設置preload: path.join(__dirname, 'preload.js'), 腳本路徑nodeIntegration:true, 配置webviewTag:true 配置},})讓窗口加載內容窗口對象.loadFile('路徑');窗口對象.loadURL('url');等到窗口內容加載完后再顯示1、設置show:false2、設置監聽窗口對象.once("ready-to-show",()=>{窗口對象.show();})子窗口不指定坐標和大小,默認和父窗口一樣大且覆蓋在上面父窗口關閉,子窗口也關閉var 子窗口對象=new BrowserWindow({x:彈出窗口x坐標y:彈出窗口y坐標parent:父窗口對象})子窗口對象.show()模態子窗口彈出改窗口后,不能點擊父窗口在子窗口的基礎上,在創建時添加屬性modal:true

文檔
渲染進程加載頁面

代碼示例:

// Modules to control application life and create native browser window const {app, BrowserWindow} = require('electron') const path = require('path')function createWindow () {// Create the browser window.const mainWindow = new BrowserWindow({width: 800,height: 600,//彈出的窗口有無邊框,默認為有// frame:false,show:false,backgroundColor:'#586148',webPreferences: {preload: path.join(__dirname, 'preload.js'),nodeIntegration:true,webviewTag:true},})// and load the index.html of the app.mainWindow.loadFile('index.html')mainWindow.webContents.on("did-finish-load",()=>{})mainWindow.webContents.on('dom-ready',()=>{})mainWindow.once('ready-to-show',function(){mainWindow.show();child.show();})var child=new BrowserWindow({x:0,y:0,//父消失,子也消失parent:mainWindow,modal:true})// Open the DevTools.// mainWindow.webContents.openDevTools() }// This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. // app.whenReady().then(createWindow) app.on('ready',()=>{createWindow();});// Quit when all windows are closed. app.on('window-all-closed', function () {// On macOS it is common for applications and their menu bar// to stay active until the user quits explicitly with Cmd + Qif (process.platform !== 'darwin') app.quit() })app.on('activate', function () {// On macOS it's common to re-create a window in the app when the// dock icon is clicked and there are no other windows open.if (BrowserWindow.getAllWindows().length === 0) createWindow() })// In this file you can include the rest of your app's specific main process // code. You can also put them in separate files and require them here.

總結

以上是生活随笔為你收集整理的electron 窗口BrowserWindow的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。