将数据传递到Windows中的电子
发布时间:2021-01-24 07:02:25 所属栏目:Windows 来源:网络整理
导读:我正在学习电子,并使用多个窗口和IPC.在我的主要脚本中,我有以下内容: var storeWindow = new BrowserWindow({ width: 400,height: 400,show: false});ipc.on('show-store-edit',function(event,store) { console.log(store); storeWindow.loadURL('file://
我正在学习电子,并使用多个窗口和IPC.在我的主要脚本中,我有以下内容: var storeWindow = new BrowserWindow({ width: 400,height: 400,show: false }); ipc.on('show-store-edit',function(event,store) { console.log(store); storeWindow.loadURL('file://' + __dirname + '/app/store.html'); storeWindow.show(); }); 在我主要的窗口脚本中,我在商店列表中的点击事件中有以下内容: $.getJSON("http://localhost:8080/stores/" + item.id).done(function(store) { ipc.send('show-store-edit',store); }); 在控制台上,我正在从我的服务器打印商店数据.我不清楚的是如何将数据存入我的storeWindow视图中:store.html.我甚至不确定我正在正确处理事件的顺序,但他们会: >单击编辑商店 要么 >单击编辑商店 在后者中,我不知道如何从storeWindow的脚本中获得从存储器获取的ID. 要将事件发送到特定窗口,您可以使用webContents.send(EVENT_NAME,ARGS)( see docs). webContents是窗口实例的属性:// main process storeWindow.webContents.send('store-data',store); 要监听正在发送的事件,您需要一个窗口进程中的监听器(渲染器): // renderer process var ipcRenderer = require('electron').ipcRenderer; ipcRenderer.on('store-data',function (store) { console.log(store); }); (编辑:鹤壁站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 修复Windows 10上的Windows Update错误0xc1900130
- windows-server-2008 – 如果你有多个域控制器,有没有理由备
- 如何配置Windows域控制器以使用外部时间服务器?
- win7系统自带的性能监视器两种开启使用方法
- 如何备份Windows Azure虚拟机?
- 如何知道Windows上次读取或访问文件的时间?
- Windows 7/Windows 10玩游戏哪个好?实测结果意外
- windows-server-2008 – 在Windows Server 2008上更改文件权
- Windows – 如何知道具有WMI的进程的CPU和内存使用情况?
- Amanda,Bacula,BackupPC哪个有可靠的Windows客户端?