我试图使用jspdf
库打印我的页面。我已经尝试了很多解决方案来完成这里的示例和几乎每个谷歌建议链接,但我仍然无法修复它。
这是我迄今为止尝试过的:
import * as jsPDF from 'jspdf';
.....
openPDF(): void {
const DATA = this.couponPage.nativeElement;
const doc = new jsPDF('p', 'pt', 'a4');
doc.fromHTML(DATA.innerHTML, 15, 15);
doc.output('dataurlnewwindow');
}
Run Code Online (Sandbox Code Playgroud)
尝试jsPDF
像上面那样导入会在编译时产生以下错误
src/...component.ts:42:21 中的错误 - 错误 TS2351:此表达式不可构造。类型 'typeof import("jspdf")' 没有构造签名。
Run Code Online (Sandbox Code Playgroud)42 const doc = new jsPDF('p', 'pt', 'a4');
因此,我尝试按照此stackoverflow 答案中的建议以另一种方式导入它
declare var jsPDF: any;
Run Code Online (Sandbox Code Playgroud)
然而,这会产生一个控制台错误,指出jsPDF
未定义。
然后我找到了另一个解决方案,如此处发布的Angular 10/9/8 PDF Tutorial – Export PDF in Angular with JSPDF
现在按照这个方法我得到了以下错误
错误类型错误:doc.fromHTML 不是函数 openPDF notice.component.ts:43 ...Component_Template_button_click_2_listener ...component.html:3 Angular …
我正在尝试按照文档本地化我的 Flutter 应用程序。
我想要实现的是,在动态构建小部件时,我想翻译来自我的模型的数据。这是我到目前为止所尝试过的
List.generate(services.length, (index) {
final Service service = services[index];
return Material(
borderRadius: BorderRadius.circular(10.0),
child: Text(
AppLocalizations.of(context).{{service.title}} // Here I wanted to translate the service title
),
);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能在 Flutter 中实现这一目标?或任何其他可能的方法来翻译动态内容。
我有一张桌子,上面列出了物品清单。我想使用 PrimeNg Menu 作为下拉菜单选项来导航到具有所选项目 ID 的其他页面。我想做的是,当我单击菜单项时,我想绑定所选项目的 id。
我的 HTML 看起来像这样
<tr *ngFor="let item of items" class="animated fadeIn">
<td>{{item.category}}</td>
<td>{{item.name}}</td>
<td>{{item.date}}</td>
<td>
<div>
<p-menu #tableMenu [popup]="true" [model]="tableMenuItems" appendTo="body"></p-menu>
<button type="button" pButton icon="pi pi-ellipsis-v"
class="ui-button-secondary ui-button-rounded ui-button-transparent"
(click)="tableMenu.toggle($event)">
</button>
</div>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
和我的.ts
this.tableMenuItems = [
{
label: 'View Item', command: (event) => {
// this.viewItemDetail() // here I wanted to bind item.id of the selected item and navigate to item detail page
}
},
{
label: 'Edit Item', command: (event) => …
Run Code Online (Sandbox Code Playgroud)