我对用于打印ionic 4的ionic native插件有问题

时间:2019-07-05 13:47:34

标签: ionic-framework printing native ionic-native

当我在android设备中运行时,此代码也有问题,ios也有同样的问题

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部署:2.0.0    NodeJS:v8.11.3(/ usr / local / bin / node)    npm:5.6.0    操作系统:macOS Mojave    Xcode:Xcode 10.2.1 Build版本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 ');
    });
  }

1 个答案:

答案 0 :(得分:0)

我通过使用相同的库安装此插件解决了我的问题 [https://github.com/isiigoteam/cordova-plugin-printer#readme][1]