18910140161

JavaScript-使用Angular在Android设备上打印-堆栈溢出

顺晟科技

2022-10-18 13:37:47

192

我有一个应用程序,需要打印页面上不存在但角度模板中存在的内容。在模板中,我有一个带有click方法的DIV,它将接受一个标识符,然后根据它收到的ID的内容构建一个iframe.第一个片段是Clickable元素的外观。

<代码><;DIV(单击)=";打印按钮('#PrintThis ')";类=";菜单项打印菜单项";>;比赛{{raceselected?.racenumber}}<;/DIV>;

这个代码片段只是一个基本元素,省略了私有数据。因此,它将只是一个带有标识符和iFrame的NG模板,我可以从下面粘贴的方法中访问它。

<代码><;ng-template#PrintThat>;//我将打印但对此问题不重要的内容<;/NG-模板>;<;ng-template#PrintThis>;//我将打印但对此问题不重要的内容<;/NG-模板>;<;iframe#iframe>;<;/iframe>;
最后

一个代码片段是构建iFrame并打开打印对话框的组件上的方法。

<div (click)="printButton('#printThis')" class="menu-item print-menu-item">Race {{ raceSelected?.raceNumber }}</div>
在上面的方法中调用

这两个私有函数,以将CSS添加到iframe.

<ng-template #printThat>
    // content that I will print but not important for this question
</ng-template>

<ng-template #printThis>
    // content that I will print but not important for this question
</ng-template>

<iframe #iframe></iframe>

这在除Android设备以外的所有设备上都没有问题。在Android上,出现“打印”对话框,但页面是空白的,没有任何内容。有没有好的Android打印解决方案,不需要带一个包,或者我在这里错过了什么?


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航