react native中使用base64加密解密

使用方法

考虑使用与和兼容的base-64,在 react 和 react native 中对我有用:btoaatob

npm install base-64 --save

或者使用yarn

yarn add base-64
import {decode as base64_decode, encode as base64_encode} from 'base-64';
let encoded = base64_encode('YOUR_DECODED_STRING');
let decoded = base64_decode('YOUR_ENCODED_STRING');

如果您正在使用打字稿,请不要忘记安装类型以及npm i --save-dev @types/base-64开发依赖项。
或者yarn 安装:

yarn add  @types/base-64 --dev

参考

https://stackoverflow.com/questions/44458874/how-to-base64-encode-inputs-in-react/44458974

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
React Native ,我们可以使用基本的组件和自定义组件来构建应用程序界面。以下是使用基本组件和自定义组件的示例: 使用基本组件: ```jsx import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; const App = () => { return ( <View style={styles.container}> <Text style={styles.text}>Hello, React Native!</Text> </View> ); }; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, text: { fontSize: 20, fontWeight: 'bold', }, }); export default App; ``` 使用自定义组件: ```jsx import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; const MyComponent = ({ title, message }) => { return ( <View style={styles.container}> <Text style={styles.title}>{title}</Text> <Text style={styles.message}>{message}</Text> </View> ); }; const App = () => { return ( <View style={styles.container}> <MyComponent title="Welcome" message="This is a custom component in React Native." /> </View> ); }; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, title: { fontSize: 24, fontWeight: 'bold', }, message: { fontSize: 16, marginVertical: 10, }, }); export default App; ``` 在上面的示例,我们定义了一个名为`MyComponent`的自定义组件,并将其作为子组件添加到`App`组件。在`MyComponent`组件,我们可以使用`props`来接收来自父组件的数据,并根据需要渲染内容。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值