From d79a4bd7699950b84788b3a22bf2f224524d1ea1 Mon Sep 17 00:00:00 2001 From: Air Date: Wed, 4 Dec 2024 09:48:50 +0000 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E5=A4=8D=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Air --- zh-cn/react-native-get-random-values.md | 360 ++++++++++++------------ 1 file changed, 180 insertions(+), 180 deletions(-) diff --git a/zh-cn/react-native-get-random-values.md b/zh-cn/react-native-get-random-values.md index e865e82a..900079e4 100644 --- a/zh-cn/react-native-get-random-values.md +++ b/zh-cn/react-native-get-random-values.md @@ -1,180 +1,180 @@ -> 模板版本:v0.2.1 - -

-

react-native-get-random-values

-

-

- - Supported platforms - - - License - - -

- -> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-get-random-values) - -## 安装与使用 - -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-get-random-values](https://github.com/react-native-oh-library/react-native-get-random-values/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 - -进入到工程目录并输入以下命令: - - - -#### **npm** - -```bash -npm install @react-native-oh-tpl/react-native-get-random-values -``` - -#### **yarn** - -```bash -yarn add @react-native-oh-tpl/react-native-get-random-values -``` - - - -下面的代码展示了这个库的基本使用场景: - -> [!WARNING] 使用时 import 的库名不变。 - -```js -import React, { useState } from "react"; -import { View, Text, StyleSheet, Button } from "react-native"; -import "react-native-get-random-values"; - -export const GetRandomValues = () => { - const [randomValue, setRandomValue] = useState < any > []; - const styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: "center", - alignItems: "center", - backgroundColor: "#F5FCFF", - }, - }); - - const clickBtn = () => { - const getRandomValues = global?.crypto?.getRandomValues(new Uint8Array(4)); - console.log(JSON.stringify(getRandomValues), "click"); - - const array = Object.values(getRandomValues); - console.log(array, "click"); - - setRandomValue(array); - }; - return ( - - 点击获取随机数 -