[英]ionic 'DocumentScanner' refers to a value, but is being used as a type here
I have the following code:我有以下代码:
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));
}
}
When i run this i get the following error:当我运行它时,我收到以下错误:
11:42 'DocumentScanner' refers to a value, but is being used as a type here.
can anyone tell me why this is happening?谁能告诉我为什么会这样?
You need to import DocumentScanner in your app.module.ts file您需要在 app.module.ts 文件中导入 DocumentScanner
import { DocumentScanner } from '@ionic-native/document-scanner/ngx';
and also add it to the provider array并将其添加到提供程序数组
providers: [
.....
DocumentScanner ,
.....
]
Also in your page.ts file, add /ngx/;同样在您的 page.ts 文件中,添加 /ngx/; after the document scanner import path like
在文档扫描仪导入路径之后
import { DocumentScanner } from '@ionic-native/document-scanner/ngx/';
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.