javascript - 使用ngx-print打印图像的问题

标签 javascript html angular angular5

图像未使用 ngx-print 打印。我不确定我在这里做错了什么。

HTML

<button  type="button" printTitle="PrintVoucher" [useExistingCss]="true" 
                                        printSectionId="printVoucher" ngxPrint>
                                        Print </button>

<div row id="printVoucher" >
 <img  src="assets/images/logo.png">
</div>

但是,图像在屏幕上可见,但在打印预览部分不可见。

enter image description here

最佳答案

必须使用绝对路径,而不是相对路径

即你的路径应该是例如

"http://localhost:3000/assets/images/print-logo.png " 不是“print-logo.png”

to know the difference between relative and absolute path check this link

要获取当前的基本网址,例如(“http://localhost:3000 ”),您可以使用

让 x = window.location.origin;

关于javascript - 使用ngx-print打印图像的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56694343/

相关文章:

javascript - 轮播导航触发 Bootstrap 的 Affix 函数

javascript - 我使用 Javascript/DOM 动态创建了一个 div。如何让 div 出现在页面上?

html - 在 CSS : Center align a text inside child DIV which is already horizontally & vertically aligned inside parent DIV 中定位

javascript - 如何在鼠标悬停时向菜单项添加和删除类

javascript - 为什么带有全局标志的正则表达式会给出错误的结果?

javascript - 如果文本区域包含特定字符串则

Angular 2 Material 自定义主题

javascript - 如何以 mat 形式将值变为小写

javascript - AngularStrap bs-select 不显示下拉菜单

javascript - Batarang 正则拦截表达式