我创建了一个生成JSON数据的Angular2应用程序.我想将此JSON输出保存到文件中,最好是PDF文件.此应用程序使用Typescript编写.
我使用jsPDF将JSON数据写入PDF文件.我通过npm使用安装了jsPDF包npm install jspdf --save.我还在index.html页面中添加了必要的链接.我在运行时对应用程序进行了这些更改.我能够将JSON数据保存到文件中.
当我停止并重新启动应用程序时,它没有按预期启动.我收到以下错误:
json-excel@1.0.0启动C:\ Users*****\Documents\Projects\Angular\json-to-pdf
tsc &&并发"npm run tsc:w""npm run lite"
app/components/app.component.ts(35,19):错误TS2304:找不到名称'jsPDF'.
我正在添加我使用过的代码.
的package.json:
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
"angular2-in-memory-web-api": "0.0.7",
"bootstrap": "^3.3.6",
"es6-shim": "^0.35.0",
"jquery": "^2.2.4",
"jspdf": "^1.2.61",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.27",
"zone.js": "^0.6.12"
}
Run Code Online (Sandbox Code Playgroud)
index.html的:
<html>
<head>
<title>JSON to PDF</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
....
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script>
....
</head>
<!-- 3. Display the application …Run Code Online (Sandbox Code Playgroud)