Raj*_*hia 6 npm node-modules cryptojs react-native
at 的包node_modules\crypto-js\core.js尝试导入 Node 标准库模块crypto。它失败了,因为本机 React 运行时不包含 Node 标准库。了解更多信息,请访问https://docs.expo.io/workflow/using-libraries/#using-third-party-libraries
运行的时候出现这个错误npm start
对于世博会而不是加密,您可以使用expo-crypto
您可以按如下方式安装它
expo install expo-crypto
在你的代码中
import React, { useEffect } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import * as Crypto from 'expo-crypto';
export default function App() {
useEffect(() => {
(async () => {
const digest = await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
'Github stars are neat'
);
console.log('Digest: ', digest);
/* Some crypto operation... */
})();
}, []);
...
as from expo documentation
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7996 次 |
| 最近记录: |