我正在尝试使用 Angular 和 Qz-Tray 打印简单的数据文本。但是每次我尝试打印时都会显示错误:
qz-tray.js:35 ReferenceError: Sha256 is not defined
at Object.hash (qz-tray.js:408)
at WebSocket._qz.websocket.connection.sendData (qz-tray.js:184)
at qz-tray.js:280
at j (rsvp.min.js:1)
at new t (rsvp.min.js:1)
at Object.promise (qz-tray.js:395)
at Object.dataPromise (qz-tray.js:272)
at Object.print (qz-tray.js:805)
at PrinterService.push../src/app/shared/services/print.service.ts.PrinterService.printData (print.service.ts:46)
at FoddListComponent.push../src/app/layout/foodlist/foddlist.component.ts.FoddListComponent.createPdf (foddlist.component.ts:122)
我在 index.html 中包含了所有 3 个 .js 文件
这是我的 index.html:
<head>
<meta charset="utf-8">
<title>ABC</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="https://cdn.jsdelivr.net/npm/rsvp@4/dist/rsvp.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-sha256/0.9.0/sha256.js"></script>
<script type="text/javascript" src="./qz-tray.js"></script>