electron v12.0.1 后一些配置的变化

设置权限

在main.js的webPreferences中加入两行配置

  const mainWindow = new BrowserWindow({

    width: 800,

    height: 600,

    webPreferences: {

      nodeIntegration : true,

      contextIsolation: false ,

      preload: path.join(__dirname, 'preload.js')

    }

  })

设置页面中的安全配置

在WEB页面的安全性配置里面改动2处:

改动前:

    

    

改动后:

    

    

在页面中调用node.js的功能函数

  

    

    

    

    

    Hello World!

  

  

    Hello World!

    We are using Node.js ,

    Chromium ,

    and Electron .

 

    

    

    

  

 

你可能感兴趣的:(web)