React Native二维码生成组件

本文原创首发于公众号:ReactNative开发圈,转载需注明出处。

React Native二维码生成组件:react-native-qrcode,纯JS组件,支持安卓和IOS双平台,支持中文和英文,可以自定义尺寸、前景色和背景色。

效果图

安装方法

npm install react-native-qrcode --save

示例代码

import React, { Component } from 'react';
import QRCode from 'react-native-qrcode';

import { AppRegistry, StyleSheet, View, TextInput, Dimensions } from 'react-native';

export default class Component09 extends Component {
  static navigationOptions = ({ navigation }) => ({
    title: `${navigation.state.params.name}`,
  });

  state = {
    text: 'https://github.com/forrest23/ReactNativeComponents',
  };

  render() {
    return (
      <View style={styles.container}>
        <TextInput
          style={styles.input}
          onChangeText={text => this.setState({ text: text })}
          value={this.state.text}
        />
        <QRCode
          value={this.state.text}
          size={200}
          bgColor="purple"
          fgColor="white"
        />
      </View>
    );
  }
}
复制代码

主要参数说明

value:二维码的值 size:大小,默认128 bgColor:背景色,默认#000 fgColor:前景是,默认#fff

完整示例

完整代码:GitHub - forrest23/ReactNativeComponents: React Native组件大全,介绍React Native常用组件的使用方法和使用示例 本次示例代码在 Component09文件夹中。请不要吝啬你们的Star

组件地址

GitHub - cssivision/react-native-qrcode: a minimalist qrcode component for react-native

微信不让跳转外链,可以点击查看原文来查看外链GitHub内容。

欢迎关注我的微信公众号:ReactNative开发圈

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值