使用uniapp开发app和微信小程序时需要使用nodejs的crypto库,但总是出现调用错误:
1、在项目中通过npm install crypto-js安装了crypto库,在项目中有node_modules目录及相关文件;
2、在js文件中通过import crypto from "crypto-js";引用后调用其相关函数,但提示不是一个函数?
import crypto from "crypto-js";
crypto.createHmac(method, Key)
编译时提示:12:31:50.977 [Vue warn]: Unhandled error during execution of onLoad \n at <Index>\nat <AsyncComponentWrapper>\nat <PageBody>\nat <Page>\nat <Anonymous>\nat <KeepAlive>\nat <RouterView>\nat <Layout>\nat <App>
12:31:51.049 [TypeError] {message: "crypto.createHmac is not a function"}
请教有遇到过类似问题的吗?如何解决?还有其他方法使用crypto的加解密函数的方法吗?
1 个回复
1***@163.com
大哥!你打印一下crypto 是没有createHmac