React Native Expo二维码生成器

4
3个回答

5

0
你可以尝试我开源的这个库:react-native-barcode-creator,它可以原生地生成QR码、Code128、AZTEC和PDF417条形码,适用于iOS和Android。

0
import React, { Component } from 'react';
import { StyleSheet, View, TextInput, TouchableOpacity, Text,} from 'react-native';
import QRCode from 'react-native-qrcode';
class App extends Component {
constructor() {
super();
this.state = {
  inputValue: '',

  valueForQRCode: '',

    };
}

  getTextInputValue = () => {
this.setState({ valueForQRCode: this.state.inputValue });
};

 render() {
return (
  <View style={styles.MainContainer}>

    <TextInput
      style={styles.TextInputStyle}
      onChangeText={text => this.setState({ inputValue: text })}
      underlineColorAndroid="transparent"
      placeholder="Enter text to Generate QR Code"
    />
    <TouchableOpacity
      onPress={this.getTextInputValue}
      activeOpacity={0.7}
      style={styles.button}>
      <Text style={styles.TextStyle}> Generate QR Code </Text>
    </TouchableOpacity>
  </View>
);
}
}
     export default App;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接