【发布时间】:2020-06-26 05:08:15
【问题描述】:
我有一个独立运行的 Angular 应用程序,并且正在尝试创建一个电子应用程序,然后它就可以运行:mainWindow.loadURL('http://localhost:4200/'); 它只是我的开发环境的本地主机,它不会是真实条件。
在电子中,我将 nodeIntegration 设置为 true,这允许我的 Angular 应用访问 ipc。
const mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
}
});
在角度我有我的乒乓球功能:
public playPingPong() {
if(this._electronService.isElectronApp) {
console.log('Is electron.')
console.log(this._electronService.ipcRenderer);
let pong: any = this._electronService.ipcRenderer.sendSync('ping', 'ping');
console.log(pong);
}
}
在使用标题中的错误记录 ipcRenderer 后,应用程序出现错误:
core.js:5845 ERROR Error: Unable to deserialize cloned data due to invalid or unsupported version.
at EventEmitter../lib/renderer/api/ipc-renderer.ts.ipcRenderer.sendSync (ipc-renderer.ts:13)
at ArcMapComponent.playPingPong (arc-map.component.ts:61)
at ArcMapComponent.ngOnInit (arc-map.component.ts:164)
at callHook (core.js:3909)
at callHooks (core.js:3873)
at executeInitAndCheckHooks (core.js:3814)
at refreshView (core.js:11723)
at refreshDynamicEmbeddedViews (core.js:13070)
at refreshView (core.js:11728)
at refreshComponent (core.js:13145)
提前谢谢你!
【问题讨论】:
-
你找到这个问题的答案了吗?我使用 Angular Electron 得到完全相同的错误消息。最新版本的 Angular/Electron/NodseJs。我正在使用最新版本的 ngx-electron...
-
使用 ipcRenderer.send 而不是 ipcRenderer.sendSync 似乎可以解决我的错误。