-
炎炎设计
您可以尝试rn-qr-generator模块(https://www.npmjs.com/package/rn-qr-generator)。您需要传递value给 lib,它会返回您uri和base64生成的 QRCode 的数据import RNQRGenerator from 'rn-qr-generator';componentDidMount() { RNQRGenerator.generate({ value: 'otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example', // required height: 300, width: 300, base64: false, // default 'false' backgroundColor: 'black', // default 'white' color: 'white', // default 'black' }) .then(response => { const { uri, width, height, base64 } = response; this.setState({ imageUri: uri }); }) .catch(error => console.log('Cannot create QR code', error)); }
-
慕娘9325324
//This is the code import React, { Component } from 'react'; import { Platform, StyleSheet, View, TextInput,Button, Image, Dimensions,ImageBackground, Text, TouchableOpacity } from 'react-native'; import { createAppContainer } from 'react-navigation'; import { createStackNavigator } from 'react-navigation-stack'; import { Buffer } from 'buffer'; import QRCode from 'react-native-qrcode-svg'; class qrDisplay extends Component{ constructor(){ super(); this.state={ } } render(){this.setState({proof:'0x0000000000000000000000000000000000000000000000000000000000000012z0x0000000000000000000000000000000000000000000000000000000000000041z0x0000000000000000000000000000000000000000000000000000000000000016z0x00000000000000000000000000000000000000000000000000000000000224b8z0x00000000000000000000000000000000000000000000000000000000002f27d0z0x01bbf2c3abaf9b1946cc6b5b199fd2cbc35ab059a53b7e986f3eab498ab6696az0x3011b16aa9a9ef1a096ddbb3d49a22191bf5309a6181e8ebbdac6d9468c64d36z0x19166accc2e39efbc939c14dc01182cc871905c6201b397680ad9cfac8105eadz0x147f7f3c3d01a4c3fe337761abe04d2c82c8d2a88b60ae6ecb0c32fe9988e926z0x293b1b75baff7688b39b725bace078f16df5d06a403f8ee248952e5dc721bdbfz0x0a9e10afbca5a473485c58021f9e84bfcaa463104158adfd4722c96ad06ec5d5z0x1dfada58ecf65b3e22b5bb5452ced64894d04fa2dfe3827911d7554f0b33f703z0x080e9e8c2ac5b8902903ac6e580eabdcd0c048b2ea27cdfcfa5434a753b61546z1'}) return( <View> <Text> YOUR QR CODE </Text> <QRCode value={this.state.proof} size={350} color="purple"/> </View> ); } } const AppNavigator = createStackNavigator( { qrDisplay:{ screen:qrDisplay, navigationOptions:{ header:null, } } }, { initialRouteName: 'qrDisplay', }, ); export default createAppContainer(AppNavigator);
-
手掌心
试试这个要点:https : //gist.github.com/marcelosalloum/14e827279e6bba1e0887c3c9f646c1aeimport React from "react";import styled from "styled-components";const QRCodeImage = styled.img<{ size: number }>` width: ${({ size }) => size}; height: ${({ size }) => size};`;type Props = { value: string; size?: number;};export const QRCode = ({ value, size = 500 }: Props) => { const uri = `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${value}`; return <QRCodeImage src={uri} size={size} />;};