Npm 我需要实现一个功能,在angular应用程序中使用热敏打印机。不幸的是,我没有尝试';我不会成功的
我正在使用ng热敏打印,但出现了一些错误。 从属关系的版本 安圭拉:6 ng热敏打印:0.1.5 package.jsonNpm 我需要实现一个功能,在angular应用程序中使用热敏打印机。不幸的是,我没有尝试';我不会成功的,npm,printing,dependencies,angular6,thermal-printer,Npm,Printing,Dependencies,Angular6,Thermal Printer,我正在使用ng热敏打印,但出现了一些错误。 从属关系的版本 安圭拉:6 ng热敏打印:0.1.5 package.json "@agm/core": "1.0.0-beta.3", "@angular/animations": "^6.1.7", "@angular-devkit/build-angular": "~0.7.0", "@angular/cli"
"@agm/core": "1.0.0-beta.3",
"@angular/animations": "^6.1.7",
"@angular-devkit/build-angular": "~0.7.0",
"@angular/cli": "~6.1.2",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "6.1.0",
"@angular/fire": "^5.0.2",
"@angular/forms": "^6.1.0",
app.component.ts
import { Component, OnDestroy } from "@angular/core";
import { ApiService } from "../../services/api.service";
import { PrintService, UsbDriver, WebPrintDriver } from "ng-thermal-print";
@Component({
selector: "app-dashboard",
templateUrl: "./dashboard.component.html",
})
export class DashboardComponent implements OnDestroy {
status: boolean = false;
usbPrintDriver: UsbDriver;
webPrintDriver: WebPrintDriver;
ip: string = "";
public constructor(
public api: ApiService,
private printService: PrintService
) {
this.usbPrintDriver = new UsbDriver();
this.printService.isConnected.subscribe((result) => {
this.status = result;
if (result) {
console.log("Connected to printer!!!");
} else {
console.log("Not connected to printer.");
}
});
}
requestUsb() {
this.usbPrintDriver.requestUsb().subscribe((result) => {
this.printService.setDriver(this.usbPrintDriver, "ESC/POS");
});
}
connectToWebPrint() {
this.webPrintDriver = new WebPrintDriver(this.ip);
this.printService.setDriver(this.webPrintDriver, "WebPRNT");
}
print(data) {
this.printService
.init()
.setBold(true)
.writeLine("Hello World")
.setBold(false)
.feed(4)
.cut("full")
.flush();
}
ngOnDestroy() {}
}
app.component.html
<button class="btn btn-success">Print Order</button>
打印顺序
我得到了一些错误,比如对象(…)不是函数
我已安装用于usb检测的@types/w3c web usb
我附上了错误的图片。
请帮帮我