不知道你具体的逻辑,以及调用API是否是异步,但从语法上来说应该加个function名称即可
- var printer = new LPAPI();
- async function printerFunc() {
- const width = 45;
- const height = 45;
- const text = "科技公司";
- if (await printer.isPrinterOpened()) {
- await printer.startJob({ width, height });
- await printer.draw2DQRCode({
- text: text,
- x: 5,
- y: 5,
- width: width - 10,
- eccLevel: 1,
- });
- await printer.commitJob();
- }
- }
- printerFunc();
复制代码
|