简体   繁体   English

使用 react JS 打印收据

[英]Print a receipt using react JS

I build a restaurant app using React JS and I want to print a receipt when the order got accepted.我使用 React JS 构建了一个餐厅应用程序,我想在订单被接受时打印收据。 The restaurant has a wifi printer and I have no idea how should I connect a printer with that website.餐厅有一台 wifi 打印机,我不知道如何将打印机连接到该网站。

There are two ways I know we can do this.我知道有两种方法可以做到这一点。

  1. Windows.print() - When added this native trigger, it'll open the regular print dialog box. Windows.print() - 添加此本机触发器后,它将打开常规打印对话框。 Which in further you can select you printer and one can take print out.您可以进一步选择打印机并打印出来。

  2. ReactToPrint - react-to-print - This library also help you to achieve the same results but in abstracted manner and some over-the-top modifications. ReactToPrint - react-to-print - 该库还可以帮助您实现相同的结果,但以抽象的方式和一些过度的修改。

Though, if you're wondering that wherever an order is placed but print should be printed then this might not help but I strongly believe that this will help you figure out something.不过,如果您想知道在何处下订单但应打印打印件,那么这可能无济于事,但我坚信这会帮助您找出一些东西。

Some other useful resources:其他一些有用的资源:

  1. React Native scan printers when connected to wifi network and get ip address of the printer 连接到 wifi 网络时响应本机扫描打印机并获取打印机的 IP 地址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM