1、安装
#安装icon生成组件
npm install react-native-svg --save
react-native link react-native-svg
#安装二维码生成组件
npm install react-native-qrcode-svg --save
2、示例及效果
import React, {Component} from 'react';
import {View} from 'react-native';
import QRCode from 'react-native-qrcode-svg';
export default class App extends Component<Props> {
constructor(props) {
super(props);
}
render() {
let logoImg = require('./src/logo.jpg');
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<QRCode
value="这是一个测试二维码..."
logo={logoImg}
logoBorderRadius={1}
color={'#191919'}
backgroundColor={'#ffffff'}
logoSize={30}
size={150}
/>
</View>
);
};
};
- 效果图
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190327150959713.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDE4NzczMA==,size_16,color_FFFFFF,t_70)
- logo.jpg文件
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190327151011182.jpg)