diff --git a/zh-cn/react-native-QRCode.md b/zh-cn/react-native-QRCode.md index 2e4340ef59de5f881875814056afb6821e289398..93a12162fecca79c10da4e3127e1ad90baeef5d8 100644 --- a/zh-cn/react-native-QRCode.md +++ b/zh-cn/react-native-QRCode.md @@ -1,6 +1,4 @@ - - -> 模板版本:v0.2.1 +> 模板版本:v0.2.2

react-native-qrcode

@@ -10,87 +8,159 @@ Supported platforms - License + +

-> [!TIP] [Github 地址](https://github.com/cssivision/react-native-qrcode) + + + +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-qrcode) ## 安装与使用 +1、此库依赖react-native-webview库,请先根据文档正确安装[react-native-webview](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-webview.md)。 + +2、请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-qrcode](https://github.com/react-native-oh-library/react-native-qrcode/releases),并下载适用版本的 tgz 包。 进入到工程目录并输入以下命令: +>[!TIP] # 处替换为 tgz 包的路径 + #### **npm** ```bash -npm install react-native-qrcode@0.2.7 +npm install @react-native-oh-tpl/react-native-qrcode@file:# ``` #### **yarn** ```bash -yarn add react-native-qrcode@0.2.7 +yarn add @react-native-oh-tpl/react-native-qrcode@file:# ``` -此库是一个React原生的生成二维码的组件,不仅仅支持英文。下面的代码展示了这个库的基本使用场景,更多详情请参考[使用教程](https://github.com/cssivision/react-native-qrcode/blob/master/README.md): + +下面的代码展示了这个库的基本使用场景: + +>[!WARNING] 使用时 import 的库名不变。 ```js -import React, { Component ,useState,useEffect } from 'react' -import { Image } from 'react-native'; +import React, {useState} from 'react'; import QRCode from 'react-native-qrcode'; -import {Animated, Text, View} from 'react-native'; - -export function QRCodeExample() { - - const qrCodeSize = 128; - - const [codeString, setCodeString] = useState(''); - - useEffect(() => { - const qr = QRCode('#fff', '#000'); - qr.addQRCodeData("http://facebook.github.io/react-native/"); - qr.build(); - const qrUrl = qr.buildDataWithURL(); - setCodeString(qrUrl); - }, ["http://facebook.github.io/react-native/"]); - - -return ( - - - - - - -); -} +import { + StyleSheet, + View, + TextInput, + Button, +} from 'react-native'; +import {TestSuite, TestCase, Tester} from '@rnoh/testerino'; +export const QrCodeExamle = () => { + const [text, setText] = useState(''); + const [QRCodeValue, setQRCodeValue] = useState(null); + const showQRCode = () => { + setQRCodeValue(text); + }; + const reset = () => { + setQRCodeValue(null); + setText(''); + }; + return ( + + + + + setText(text)} + value={text} + /> + +