首页 > 解决方案 > 我对用于打印 ionic 4 的 ionic 本机插件有问题

问题描述

当我在 android 设备上运行时,我遇到了这段代码的问题,我也遇到了同样的问题

TypeError: Printer.getPlugin(...).check is not a function
    at vendor.js:79303
    at vendor.js:78443
    at new ZoneAwarePromise (polyfills.js:3272)
    at tryNativePromise (vendor.js:78442)
    at getPromise (vendor.js:78463)
    at vendor.js:79301
    at Printer.push../node_modules/@ionic-native/printer/ngx/index.js.Printer.check (vendor.js:79308)
    at Printer.push../node_modules/@ionic-native/printer/ngx/index.js.Printer.isAvailable (vendor.js:79294)
    at SaleInfoPage.push../src/app/paenter code herege/sale-info/sale-info.page.ts.SaleInfoPage.print (main.js:1037)
    at Object.eval [as handleEvent] (SaleInfoPage.html:54)

离子信息

离子:

离子 CLI:5.2.1 (/usr/local/lib/node_modules/ionic) 离子框架:@ionic/angular 4.6.0 @angular-devkit/build-angular:0.13.9 @angular-devkit/schematics:7.3.9 @angular/cli:7.3.9 @ionic/angular-toolkit:1.5.1

科尔多瓦:

Cordova CLI:8.0.0 Cordova 平台:android 8.0.0,ios 4.5.5 Cordova 插件:cordova-plugin-ionic-keyboard 2.1.3,cordova-plugin-ionic-webview 4.1.1,(和其他 9 个插件)

效用:

cordova-res:0.5.0(可用更新:0.5.2)本机运行:0.2.6(可用更新:0.2.7)

系统:

Android SDK 工具:26.1.1 (/Users/shahab/Library/Android/sdk/) ios-deploy:2.0.0 NodeJS:v8.11.3 (/usr/local/bin/node) npm:5.6.0 操作系统:macOS Mojave Xcode:Xcode 10.2.1 构建版本 10E

函数中的代码

print()
  {
    this.printer.isAvailable().then(function(){
      this.printer.print("https://www.techiediaries.com").then(function(){
            alert("printing done successfully !");
          },function(){
            alert("Error while printing !");
          });
    }, function(e){
        console.log(e);
        alert('Error : printing is unavailable on your device ');
    });
  }

标签: ionic-frameworkprintingnativeionic-native

解决方案


我通过使用相同的库isiigoteam/cordova-plugin-printer安装这个插件解决了我的问题


推荐阅读