react-native 生成二维码

react-native 生成二维码

先上效果


2
使用的开源库

react-native-qrcode

配置方式

Installation

npm install react-native-qrcode --save

Usage

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

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

class HelloWorld extends Component {
  state = {
    text: 'http://facebook.github.io/react-native/',
  };

  render() {
    return (
      
         this.setState({text: text})}
          value={this.state.text}
        />
        
      
    );
  };
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: 'white',
        alignItems: 'center',
        justifyContent: 'center'
    },

    input: {
        height: 40,
        borderColor: 'gray',
        borderWidth: 1,
        margin: 10,
        borderRadius: 5,
        padding: 5,
    }
});

AppRegistry.registerComponent('HelloWorld', () => HelloWorld);

module.exports = HelloWorld;

关注公众号获取更多内容

react-native 生成二维码_第1张图片

你可能感兴趣的:(react-native 生成二维码)