简体   繁体   English

ionic 'DocumentScanner' 指的是一个值,但在这里被用作一个类型

[英]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.希望能帮助到你。

As mentioned here , if any file in your project has a missing /ngx import, it may cause issues even in files where /ngx is present.如此所述,如果项目中的任何文件缺少/ngx导入,即使在/ngx存在的文件中也可能导致问题。

So you should check every file for missing /ngx imports.因此,您应该检查每个文件是否缺少/ngx导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 'ItemIsLoading'on指的是一种类型,但此处被用作值 - 'ItemIsLoading' on refers to a type, but is being used as a value here 指的是一个值,但在这里被用作一个类型 - refers to a value, but is being used as a type here 元素指的是一个值,但在这里被用作类型 - element refers to a value, but is being used as a type here NPM模块“仅指类型,但在此处用作值。”在Ionic 2 / Angular 2中 - NPM module “only refers to a type, but is being used as a value here.” in Ionic 2 / Angular 2 导出时类型“仅指一种类型,但在此处用作值” - Type “only refers to a type, but is being used as a value here” when exporting “承诺”仅指类型,但在此处用作值 - 'Promise' only refers to a type, but is being used as a value here “'输出'仅指一种类型,但在此处使用了一个值”错误 - "'Output' only refers to a type, but is being used a value here" error “post”仅指一种类型,但在此处用作值 - 'post' only refers to a type, but is being used as a value here 'MapEditServiceConfig'仅引用类型,但在此处用作值 - 'MapEditServiceConfig' only refers to a type, but is being used as a value here IFormContext 只引用一个类型,但在这里用作一个值 - IFormContext only refers to a type, but is used as a value here
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM