我正在使用打印工具,我尝试按如下方式查找打印机
this.Printers = qz.websocket.connect().then(() => {
return qzTray.printers.find("found a printer");
}).then((found) => {
this.Printers = found;
return this.Printers;
}).catch((e) => {
console.log('failed printing');
this.Printers=null;
return this.printers
}
因此,当上述运行并找到打印机时 this.Printers 的值为。哪个是对的
this.Printers = "Found a printer"
但是当我找不到打印机时 this.Printers 看起来像
Promise {<pending>}__proto__: Promise[[PromiseState]]: "pending"[[PromiseResult]]: undefined
所以在我的捕获i tried
中分配this.Printers=null
为一个测试,看看它是否会返回,但我仍然没有得到
Promise {<pending>}__proto__: Promise[[PromiseState]]: "pending"[[PromiseResult]]: undefined
当 this.Printers无法使用 [[PromiseResult]]: undefined 或 null 时,如何分配它?