rn局域网连接打印机
安装
1.使用npm安装:
npm install react-native-print --save
2.react-native link(RN版本06.0不需要执行此操作 06.0会自动依赖)
Demo代码:
import React, { Component } from 'react';
import {
AppRegistry,
Button,
StyleSheet,
NativeModules,
Platform,
Text,
View
} from 'react-native';
import RNPrint from 'react-native-print';
export default class RNPrintExample extends Component {
state = {
selectedPrinter: null
}
// @NOTE iOS Only
selectPrinter = async () => {
const selectedPrinter = await RNPrint.selectPrinter({ x: 100, y: 100 })
this.setState({ selectedPrinter })
}
// @NOTE iOS Only
silentPrint = async () => {
if (!this.state.selectedPrinter) {
alert('Must Select Printer First')
}
const jobName = await RNPrint.print({
printerURL: this.state.se
React-native实现局域网打印

本文介绍了如何在React-native应用中实现局域网内打印机的连接和使用。首先通过npm安装react-native-print库,并详细说明了安装步骤,包括RN版本0.60及以上版本的自动依赖处理。接着,提供了Demo代码示例,展示如何在实际项目中运用这个库进行打印操作。
最低0.47元/天 解锁文章
2493

被折叠的 条评论
为什么被折叠?



