百度地图网站后台更新,青海哪家做网站的公司最大,秦皇岛公司做网站,邦策网站建设1 渲染进程调用主进程得方法 下面是渲染进程得代码:
let { ipcRenderer} require( electron );
ipcRenderer.send( xxx ); //渲染进程中调用
下面是主进程得代码:
var { ipcMain } require( electron ); ipcMain.on(xxx,function () { } ) 2 渲染进程与…1 渲染进程调用主进程得方法 下面是渲染进程得代码:
let { ipcRenderer} require( electron );
ipcRenderer.send( xxx ); //渲染进程中调用
下面是主进程得代码:
var { ipcMain } require( electron ); ipcMain.on(xxx,function () { } ) 2 渲染进程与渲染进程之间的传值
使用remote.BrowserWindow在某个渲染进程中打开一个新窗口并向新窗口中传值
xxxrWindow new remote.BrowserWindow( {webPreferences: {nodeIntegration: true},show: true} );xxxrWindow.webContents.on( did-finish-load, () {xxxrWindow.webContents.send( data, JSON.stringify(passInfo) );remote.getCurrentWindow().close();//关闭当前窗口} );然后在新窗口中html开始Script标签内加入接收监听代码 //数据监听const ipc require(electron).ipcRenderer;ipc.on(data, (e,arg) {console.log(uu);console.log(arg)});注意 注意 注意 消息发送后才能关闭当前窗口否则 打开的新窗口是接收不到消息的
也就是remote.getCurrentWindow().close(); 这行代码要写在上面的回调里面保证代码发送完毕后才关掉当前窗口如果这行代码写在外面窗口会先于代码发送关掉这样代码发送就没执行 FRhunkXu