安装elliptic包成功后,进行npm构建,示例代码在本地node环境可以正常运行,但是在微信小程序端运行报错如下:
VM6216:1 thirdScriptError
Cannot read property 'getBytes' of null
TypeError: Cannot read property 'getBytes' of null
at Rand._rand (http://127.0.0.1:56989/appservice/miniprogram_npm/elliptic/miniprogram_npm/brorand/index.js:99:21)
at Rand.generate (http://127.0.0.1:56989/appservice/miniprogram_npm/elliptic/miniprogram_npm/brorand/index.js:94:19)
at rand (http://127.0.0.1:56989/appservice/miniprogram_npm/elliptic/miniprogram_npm/brorand/index.js:84:16)
at EC.genKeyPair (http://127.0.0.1:56989/appservice/miniprogram_npm/elliptic/index.js:2327:37)
at http://127.0.0.1:56989/appservice/pages/index/index.js:18:14
at require (http://127.0.0.1:56989/appservice/__dev__/WAService.js:2:1680701)
at <anonymous>:164:7
at HTMLScriptElement.scriptLoaded (http://127.0.0.1:56989/appservice/appservice?t=1581906450710:4521:21)
at HTMLScriptElement.script.onload (http://127.0.0.1:56989/appservice/appservice?t=1581906450710:4533:20)
如何解决呢,是因为调用了nodejs内置函数吗,所以这个第三方包不能使用?
可以用cdn的包引用
请问怎么解决的,这个库,在h5我试了是可以的, 在小程序就会报错。 有没详细的解决步骤
请问大佬解决了吗,同遇到这个问题
var CryptoJS = require('./../crypto-js/index.js');
return CryptoJS.lib.WordArray.random(nBytes).words;