我是Electron JS的新手,我使用ipcRenderer进行打印,这是我调用ipcRenderer.Send()的代码
this.orderService.ItemDictionaryForPrint.forEach(element => {
var PrintterName = null;
let KOTNoPrintContents = document.getElementById(element.KOTNo).innerHTML;
this._electronService.ipcRenderer.send('printKOT', `
<html>
<head>
</head>
<body>${KOTNoPrintContents}</body>
</html>`);
});
main.js中的代码
ipcMain.on("printKOT", (event, content) => {
printWindow = new BrowserWindow({parent: win, modal: true, show: false})
printWindow.loadURL("data:text/html;charset=utf-8," + encodeURI(content));
printWindow.webContents.on('did-finish-load', () => {
printWindow.webContents.print({ silent: isSilent });
printWindow = null;
});
printWindow.on('closed', function () { printWindow = null })
});
但是出现类似enter image description here
这样的错误的代码有什么办法可以让我使用ipcRenderer.Send in loop?