离子原生打印机插件无法正常工作。打印机插件是否需要特殊的初始化步骤?

时间:2017-11-20 17:54:42

标签: cordova plugins printing

我已经回顾了其他人之前发布的相同问题(Ionic native Printer plugin not working),但我已经完成了那里提到的所有事情,但仍然无效。它总是说设备上没有拾取/打印。

this.printer.pick().then(function() {
    alert("Picking printer done successfully !");
}, function() {
    alert('Error : picking printer unavailable on your device ');
});

this.printer.isAvailable().then(function() {
    this.printer.print(page, options).then(function() {
        alert("printing done successfully !");
    }, function() {
        alert("Error while printing !");
    });
}, function() {
    alert('Error : printing is unavailable on your device ');
});

1 个答案:

答案 0 :(得分:0)

避免在另一个函数中使用“ function()”。试试这个

this.printer.pick().then(pickSuccess => {
    alert("Picking printer done successfully !");
}, pickError => {
    alert('Error : picking printer unavailable on your device ');
});

this.printer.isAvailable().then(isAvailableSuccess => {
    this.printer.print(page, options).then(printSuccess => {
        alert("printing done successfully !");
    }, printError => {
        alert("Error while printing !");
    });
}, isAvailableError => {
    alert('Error : printing is unavailable on your device ');
});