a usb thermal printer library for android
npm install react-native-usb-printerA React Native Library to support USB printer for Android platform
```
npm install react-native-usb-printer --save
To integrate react-native-usb-printer with the rest of your react app just execute:``
react-native link react-native-usb-printer
`javascript
import { RNUSBPrinter } from 'react-native-usb-printer';
RNUSBPrinter.printText('这是一个测试打印')
RNUSBPrinter.printBillTextWithCut("
RNUSBPrinter.printBillTextWithCut("
RNUSBPrinter.printBillTextWithCut("
`
`javascript
componentDidMount = async () => {
var devices = await RNUSBPrinter.getUSBDeviceList();
vendorID = 1155
productId = 22304
let printedSelected = await RNUSBPrinter.connectPrinter(vendorId, productId);
this.setState(Object.assign({}, this.state, {
printedSelected: printedSelected,
devices: devices,
}));
}
printTest = () => {
if(this.state.printedSelected) {
RNUSBPrinter.printText("
}else{
console.log("没有找到打印设备")
}
}
printRawDataTest = () => {
if(this.state.printedSelected) {
RNUSBPrinter.printBillTextWithCut("
}else{
console.log("没有找到打印设备")
}
}
...
render() {
return (
{
this.state.deviceList.map(device => (
{device_name: ${device.device_name}, device_id: ${device.device_id}, vendor_id: ${device.vendor_id}, product_id: ${device.product_id}}
))
}
)
}
...
``