Javascript Electron.NETBlazor使用js打开新窗口
我试图通过点击按钮打开新窗口Javascript Electron.NETBlazor使用js打开新窗口,javascript,c#,electron,blazor,Javascript,C#,Electron,Blazor,我试图通过点击按钮打开新窗口 <input type="button" @onclick="CallUpdate" value="Print!" /> 在浏览器中,这项工作很好 我在c#方法中调用js(问题出现在“printWindow.document.write”行('请参见以下注释: Cannot read property 'write' of undefined TypeError: Cannot read pr
<input type="button" @onclick="CallUpdate" value="Print!" />
在浏览器中,这项工作很好
我在c#方法中调用js(问题出现在“printWindow.document.write”行('请参见以下注释:
Cannot read property 'write' of undefined TypeError: Cannot read property 'write' of undefined at window.updateAfterPrintJS (http://localhost:8001/myscript.js:11:26)
protected async Task CallUpdate()
{
try{
await JS.InvokeVoidAsync("updateAfterPrintJS",DotNetObjectReference.Create(invokeHelper));
}
catch(Exception ex)
{
log = ex.Message;
}
}
window.updateAfterPrintJS = (dotnetHelper) => {
var divContents = document.getElementById("printableArea").innerHTML;
var printWindow = window.open('', '', 'height=200,width=400');
printWindow.document.write('<html><head><title></title>');
printWindow.document.write('</head><body >');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
printWindow.close();
dotnetHelper.invokeMethodAsync('Drycleaning');
}