多次调用时,ipcrenderer.send无法正常工作

时间:2018-07-17 11:14:40

标签: angularjs electron

我是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?

0 个答案:

没有答案
相关问题