首页 > 解决方案 > Ionic 3 -> TypeError: Printer_1.getPlugin(...).check 不是函数

问题描述

我检查了这个问题的论坛,我发现了这篇文章(https://forum.ionicframework.com/t/native-printer-plugin-not-working/92148)这正是发生在我身上但我无法解决它:皱眉:

这是一个 Ionic 3 项目。

如果有人可以请帮助我,我会在这里提供我可以提供的所有信息。我可以说这是一个遗留项目(我不知道编程中的遗留是否与我想解释的术语相同。A 人开始项目,而我作为 B 人继续项目。)

Ionic:

   Ionic CLI          : 6.16.3 (/Users/samy/.nvm/versions/node/v11.9.0/lib/node_modules/@ionic/cli)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.3

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : 9.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 2.5.2, (and 19 other plugins)

Utility:

   cordova-res (update available: 0.15.3) : 0.6.0
   native-run (update available: 1.4.0)   : 1.3.0

System:

   Android SDK Tools : 26.1.1 (/Users/samy/Library/Android/sdk)
   NodeJS            : v11.9.0 (/Users/samy/.nvm/versions/node/v11.9.0/bin/node)
   npm               : 7.9.0
   OS                : macOS Big Sur

package.json 如下:

{
  "name": "app",
  "version": "0.2",
  "author": "",
  "homepage": "",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/ble": "^4.19.0",
    "@ionic-native/core": "^4.11.0",
     "@ionic-native/email-composer": "^4.20.0",
     "@ionic-native/file": "^4.20.0",
     "@ionic-native/file-transfer": "^5.14.0",
     "@ionic-native/ftp": "^4.20.0",
     "@ionic-native/http": "^4.20.0",
     "@ionic-native/keyboard": "^5.10.0",
     "@ionic-native/native-audio": "^4.20.0",
     "@ionic-native/network": "^4.20.0",
     "@ionic-native/network-interface": "^4.20.0",
     "@ionic-native/printer": "^4.20.0",
     "@ionic-native/splash-screen": "~4.17.0",
     "@ionic-native/sqlite": "^4.19.0",
     "@ionic-native/status-bar": "^4.20.0",
     "@ionic/app-scripts": "3.2.3",
     "@ionic/pro": "2.0.4",
     "@ionic/storage": "^2.2.0",
     "angular2-uuid": "^1.1.1",
     "cordova": "^10.0.0",
     "cordova-android-support-gradle-release": "^3.0.1",
     "cordova-browser": "5.0.4",
     "cordova-pdf-generator": "^2.0.8",
     "cordova-plugin-advanced-http": "^2.3.1",
     "cordova-plugin-ble-central": "~1.2.2",
     "cordova-plugin-compat": "^1.2.0",
     "cordova-plugin-device": "^2.0.2",
     "cordova-plugin-email-composer": "^0.9.2",
     "cordova-plugin-file": "~6.0.1",
     "cordova-plugin-file-transfer": "^1.7.1",
     "cordova-plugin-ftp": "^1.1.1",
     "cordova-plugin-ionic-keyboard": "^2.1.3",
     "cordova-plugin-ionic-webview": "^2.3.1",
     "cordova-plugin-nativeaudio": "^3.0.9",
     "cordova-plugin-network-information": "^2.0.2",
     "cordova-plugin-networkinterface": "^2.0.0",
     "cordova-plugin-printer": "git+https://github.com/katzer/cordova-plugin-printer.git",
     "cordova-plugin-shell-exec": "^1.0.0",
     "cordova-plugin-splashscreen": "^5.0.3",
     "cordova-plugin-statusbar": "^2.4.3",
     "cordova-plugin-whitelist": "^1.3.4",
     "cordova-res": "^0.6.0",
     "cordova-sqlite-storage": "^3.4.0",
     "global": "^4.4.0",
     "ionic-angular": "3.9.2",
     "ionicons": "3.0.0",
     "mobx": "^5.14.0",
     "mobx-angular": "^3.0.1",
     "rxjs": "5.5.11",
     "sw-toolbox": "3.6.0",
     "zone.js": "0.8.26"
   },
   "devDependencies": {
     "cordova-android": "^9.1.0",
     "galletas-plugin-sql-server": "file:../galletas-plugin-sql-server",
     "send-mail-cordova-plugin": "file:../com.autentia.plugin.sendmail",
     "typescript": "~2.6.2"
   },
   "description": "App Quely comerciales autoventa.",
   "cordova": {
     "plugins": {
       "cordova-plugin-whitelist": {},
       "cordova-plugin-statusbar": {},
       "cordova-plugin-device": {},
       "cordova-plugin-splashscreen": {},
       "cordova-plugin-ionic-webview": {},
       "cordova-plugin-ionic-keyboard": {},
       "cordova-plugin-ble-central": {},
       "cordova-plugin-file": {},
       "cordova-plugin-advanced-http": {},
       "cordova-plugin-printer": {
         "ANDROID_SUPPORT_V4_VERSION": "28.+"
       },
       "cordova-android-support-gradle-release": {
         "ANDROID_SUPPORT_VERSION": "27.+"
       },
       "cordova-sqlite-storage": {},
       "cordova-plugin-nativeaudio": {},
       "cordova-plugin-email-composer": {},
       "cordova-plugin-ftp": {},
       "cordova-plugin-file-transfer": {},
       "cordova-pdf-generator": {},
       "cordova-plugin-network-information": {},
       "cordova-plugin-networkinterface": {},
       "org.apache.cordova.shell-exec": {},
       "com.autentia.plugin.sendmail": {},
       "galletas-plugin-sql-server": {}
     },
     "platforms": [
       "browser",
       "android"
     ]
   }
 }

当我执行 this.printer.isAvailable() 时,错误如下:

vendor.js:sourcemap:2134 ERROR Error: Uncaught (in promise): TypeError: Printer_1.getPlugin(...).check is not a function
TypeError: Printer_1.getPlugin(...).check is not a function
    at vendor.js:61288
    at new t (polyfills.js:3)
    at Printer.check (vendor.js:61286)
    at Printer.value [as check] (vendor.js:135283)
    at Printer.isAvailable (vendor.js:61270)
    at VentasPage.<anonymous> (main.js:2092)
    at step (main.js:1903)
    at Object.next (main.js:1884)
    at fulfilled (main.js:1875)
    at t.invoke (polyfills.js:3)
    at c (polyfills.js:3)
    at c (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (vendor.js:5436)
    at t.invokeTask (polyfills.js:3)
    at r.runTask (polyfills.js:3)
    at o (polyfills.js:3)

我有点绝望,因为这是为了我的公司,所以......请......我祈祷你的帮助。

非常感谢,山姆

标签: androidcordovaionic-frameworkionic3cordova-plugins

解决方案


推荐阅读