ionic-framework - 我对用于打印 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 ');
});
}
解决方案
我通过使用相同的库isiigoteam/cordova-plugin-printer安装这个插件解决了我的问题
推荐阅读
- performance - 如何分析所有同名进程?
- javascript - Clockpicker滚动而不是更改时间
- c - 链表函数在第一个节点而不是路径中打印 NULL
- c++ - 为什么以下模板化的类成员函数无法编译?
- python - 给定许多文本示例,对一些从未见过的文本进行分类
- python - 基于外键关系的Django sum(涉及3个模型)
- javascript - 如何从嵌套的 JSON 有效负载 (JavaScript) 中删除特定元素?
- java - Android 移动导航 - 未生成 NavController Action 类
- reactjs - 如何使用该 API?反应抓取
- tmux - 是否可以使用 vim 键绑定从 PuTTY 上的 tmux 将文本复制到我的 Windows 10 剪贴板?