将数据传递到Windows中的电子
发布时间:2021-01-23 23:12:22 所属栏目: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-server-2008 – 如何监控Dell服务器上的冗余电源?
- win7开启无限自动修复解决方案
- Windows Forms .NET中的热键(非全局)
- Win10系统下电脑使用全民WiFi提醒wifi创建失败怎么办
- windows – 错误设置stunnel服务器:`SSL3_GET_CLIENT_HELL
- windows-server-2008-r2 – Windows / NTFS – 是否可以测量
- 旗舰windows7系统安装版本方法介绍
- windows-server-2008-r2 – 禁止,减慢或停止对RDP的大量登录
- Windows 10系统,专业版与企业版有什么区别?
- win7系统隐藏文件怎么显示制作步骤
站长推荐
热点阅读

