欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Electron渲染进程调用主进程

程序员文章站 2022-06-04 19:36:09
...

Electron渲染进程调用主进程

引用

  1. const BrowerWindow = require(“electron”).remote.BrowserWindow;

  2. const { remote } = require(“electron”);

    const BrowerWindow = remote.BrowserWindow;

应用

    var contentDom = document.querySelector('#index');

    const BrowerWindow = require("electron").remote.BrowserWindow;
    contentDom.onclick = () =>{
        let win = new BrowerWindow({
            width: 300,
            height: 200,
            frame: false,
            transparent: true
        })
        win.loadURL(path.join('file:',__dirname,'news.html'));
        win.on('close',()=>{win = null});
    }

在主进程写入:

        webPreferences:{
            enableRemoteModule: true
        }