ReactNative二维码扫描
来源:互联网 发布:20端口是什么 编辑:程序博客网 时间:2024/06/05 11:02
二维码扫描,其实也并没有什么神奇的东西,解码规则别人也已经封装好了,我们只需要调用就好了,那么当然就需要第三方库。。。
操作流程如下:
1、下载第三方库:npm i --save react-native-barcodescanner
2、配置该库:react-native link
3、直接引入使用就得了。。。案例如下:
import React, {
AppRegistry,
Component,
} from 'react-native';import BarcodeScanner from 'react-native-barcodescanner';
class BarcodeScannerApp extends Component {
constructor(props) {
super(props);
this.state = {
torchMode: 'off',
cameraType: 'back',
};
}
barcodeReceived(e) {
console.log('Barcode: ' + e.data);
console.log('Type: ' + e.type);
}
render() {
return (
<BarcodeScanner
onBarCodeRead={this.barcodeReceived}
style={{ flex: 1 }}
torchMode={this.state.torchMode} //点击对焦,’on’ /‘off’
cameraType={this.state.cameraType} //前置摄像头还是后置摄像头,‘back’/‘front’ ,默认‘back’后置摄像头
/>
);
}
}
AppRegistry.registerComponent('BarcodeScannerApp', () => BarcodeScannerApp);
想了解更多请打开下面网站:
https://github.com/ideacreation/react-native-barcodescanner
- ReactNative二维码扫描
- (七)ReactNative实现二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 扫描二维码
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 扫描二维码
- 二维码扫描
- HashMap的工作原理
- 素数筛法(素筛)
- js页面跳转并传值的常用方法
- 为何大量网站不能抓取?爬虫突破封禁的6种常见方法
- SpringBoot热部署
- ReactNative二维码扫描
- 最大子矩阵
- 源码编译安装Apache开机自启动
- Android源码编译步骤
- Java面试题
- poj1160 [IOI2000] Post Office(区间dp+四边形不等式)
- python中的内建属性
- Hrbust 2310 Tree Painting(欧拉路径性质)
- ReactNative之SideMenu