![](/img/trans.png)
[英]'ItemIsLoading' on refers to a type, but is being used as a value here
[英]ionic 'DocumentScanner' refers to a value, but is being used as a type here
我有以下代碼:
import {Component} from '@angular/core';
import {DocumentScanner, DocumentScannerOptions, DocumentScannerSourceType} from '@ionic-native/document-scanner';
@Component({
selector: 'app-tab2',
templateUrl: 'tab2.page.html',
styleUrls: ['tab2.page.scss']
})
export class Tab2Page {
constructor(private documentScanner: DocumentScanner) {
}
scan() {
const opts: DocumentScannerOptions = {
sourceType: DocumentScannerSourceType.CAMERA,
fileName: 'ticketScan.png',
quality: 100,
returnBase64: true
};
this.documentScanner.scanDoc(opts)
.then((res: string) => console.log(res))
.catch((error: any) => console.error(error));
}
}
當我運行它時,我收到以下錯誤:
11:42 'DocumentScanner' refers to a value, but is being used as a type here.
誰能告訴我為什么會這樣?
您需要在 app.module.ts 文件中導入 DocumentScanner
import { DocumentScanner } from '@ionic-native/document-scanner/ngx';
並將其添加到提供程序數組
providers: [
.....
DocumentScanner ,
.....
]
同樣在您的 page.ts 文件中,添加 /ngx/; 在文檔掃描儀導入路徑之后
import { DocumentScanner } from '@ionic-native/document-scanner/ngx/';
希望能幫助到你。
如此處所述,如果項目中的任何文件缺少/ngx
導入,即使在/ngx
存在的文件中也可能導致問題。
因此,您應該檢查每個文件是否缺少/ngx
導入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.