如何隱藏electron窗體的菜單欄


electron中默認帶有頂部菜單欄,有時候我們的應用不需要。

再main.js文件中設置

const electron = require('electron')

const path = require('path')
const url = require('url')

let mainWindow
const Menu = electron.Menu
function createWindow () {
 
// 隱藏菜單欄
  Menu.setApplicationMenu(null)
  // Create the browser window.設置窗口寬高,最小寬高,圖標等
  mainWindow = new BrowserWindow({ width: 800, height: 600, minWidth: 1280, minHeight: 800, resizable: false, allowRunningInsecureContent: true, experimentalCanvasFeatures: true, icon: './favicon.ico'})
  mainWindow.loadURL("http://www.nlfit.cn/saas/index.html#/login")
 
  mainWindow.on('closed', function () {
    mainWindow = null
  })
}

 

const electron = require( 'electron')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.

// const app = electron.app
// const BrowserWindow = electron.BrowserWindow
const path = require( 'path')
const url = require( 'url')

let mainWindow
const Menu = electron. Menu
function createWindow () {
Menu. setApplicationMenu( null)
// Create the browser window.
mainWindow = new BrowserWindow({ width: 800, height: 600, minWidth: 1280, minHeight: 800, resizable: false, allowRunningInsecureContent: true, experimentalCanvasFeatures: true, icon: './favicon.ico'})
// and load the index.html of the app.
mainWindow. loadURL( "http://www.nlfit.cn/saas/index.html#/login")
// 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
})
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM