【发布时间】:2018-05-12 14:37:50
【问题描述】:
目前使用带有 Angular 和 Firebase 的 PDF-Viewer,我不断收到运行时错误“无法绑定到 'src',因为它不是 'pdf-viewer' 的已知属性”。
有谁知道这是为什么?这是我的依赖列表:
"dependencies": {
"@angular/common": "4.4.3",
"@angular/compiler": "4.4.3",
"@angular/compiler-cli": "4.4.3",
"@angular/core": "4.4.3",
"@angular/forms": "4.4.3",
"@angular/http": "4.4.3",
"@angular/platform-browser": "4.4.3",
"@angular/platform-browser-dynamic": "4.4.3",
"@ionic-native/core": "4.3.2",
"@ionic-native/file": "^4.4.2",
"@ionic-native/file-opener": "^4.4.2",
"@ionic-native/splash-screen": "4.3.2",
"@ionic-native/status-bar": "4.3.2",
"@ionic/storage": "2.0.1",
"@types/html2canvas": "^0.5.35",
"@types/jspdf": "^1.1.31",
"cordova-android": "6.3.0",
"cordova-pdf-generator": "^1.9.3",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-file": "^5.0.0",
"angularfire2": "^5.0.0-rc.4",
"cordova-browser": "5.0.1",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-file-opener2": "^2.0.19",
"cordova-plugin-file-transfer": "^1.7.0",
"cordova-plugin-ionic-webview": "^1.1.16",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.3.0",
"cordova-plugin-whitelist": "^1.3.1",
"firebase": "^4.6.1",
"html2canvas": "^0.5.0-beta4",
"ionic-angular": "3.7.1",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"jspdf": "^1.3.5",
"ng2-pdf-viewer": "^3.0.2",
"rxjs": "5.4.3",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"@ionic/app-scripts": "3.0.1",
"typescript": "2.3.4"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-device": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-file": {},
"cordova-plugin-file-transfer": {},
"cordova-pdf-generator": {},
"cordova-plugin-file-opener2": {}
},
"platforms": [
"browser",
"android"
]
}
我尝试将依赖项回滚到早期状态,但这似乎只会导致更多问题。任何帮助将不胜感激。
我使用过 pdf 查看器的一个区域
<div id="pdfPreview">
<pdf-viewer [src]="srcPdf" [render-text]="true" [page]="1" [original-size]="false"
style="display: block;"
></pdf-viewer>
<!--<img
src="assets/img/45SeroAhRyuPNagS090v_
DM2AjubpQ1SXM2UlmWa8_PeterWyrostekTicketApp
eal123456.jpg" style="display:block;width:100%;height:auto;margin-
left:auto;margin-right:auto;" />-->
</div>
我使用pdf查看器的另一个领域:
<div>
<pdf-viewer [src]="srcPdf" [render-text]="true" [page]="1" [original-size]="false"
style="display: block;"
></pdf-viewer>
<!--<img src="data:image/jpeg;base64, img" style="display:block;width:100%;height:auto;margin-left:auto;margin-right:auto;" />-->
</div>
错误日志:
syntaxError@http://localhost:8107/build/vendor.js:94243:39
parse@http://localhost:8107/build/vendor.js:105481:30
_compileTemplate@http://localhost:8107/build/vendor.js:119675:44
forEach@[native code]
_compileComponents@http://localhost:8107/build/vendor.js:119594:26
http://localhost:8107/build/vendor.js:119481:37
compileModuleAsync@http://localhost:8107/build/vendor.js:119409:64
_bootstrapModuleWithZone@http://localhost:8107/build/vendor.js:4893:43
http://localhost:8107/build/main.js:3904:124
__webpack_require__@http://localhost:8107/build/vendor.js:55:34
webpackJsonpCallback@http://localhost:8107/build/vendor.js:26:42
global code@http://localhost:8107/build/main.js:1:13
如果我没看错,是不是 vendor.js 中有语法错误?我认为这是构建时自动生成的?
【问题讨论】:
-
你从哪里得到错误信息?
-
您需要向我们展示您在代码中的何处使用了 pdf-viewer。
-
@ObsidianAge android 应用程序加载。
-
我的意思是它说错误消息来自哪行代码?如,该插件是如何被引用的?您可以使用 F12 开发人员工具逐步检查错误,以准确查看它何时被抛出。
-
@Melchia 更新
标签: angular cordova ionic-framework ionic2 ionic3