VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > .net教程 >
  • ASP.net教程之关于electron中入口文件main.js一些重要

 
const {app, BrowserWindow} = require('electron')
const path = require('path')
 
 
let mainWindow
function createWindow () {
  console.log(123)
  mainWindow = new BrowserWindow({
    width: 900,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration:true//设置此项以使用nodejs
    },
    frame:true
  })
 
 
  mainWindow.loadFile('main.html')
  
  mainWindow.on('closed'function () {
    
    mainWindow = null
  })
}
 
 
app.on('ready', createWindow)
 
app.on('window-all-closed'function () {
  if (process.platform !== 'darwin') app.quit()
})
 
app.on('activate'function () {
  if (mainWindow === null) createWindow()
})

  第一次发博:

      在函数createWindow中设置第一个渲染进程mainWindow里有一个webpreferences,里面的第一个参数暂不知道,也许后续会更新。第二个参数是如果当前进程所使用的的html文件需要用到nodejs模块则必须加这个参数,且设置为true,否则所有目标html文件中的nodejs语句都会失效

相关教程