【问题标题】:Using Web Crypto API in NextJS, but getting error 'crypto is not defined'在 NextJS 中使用 Web Crypto API,但出现错误 \'crypto is not defined\'
【发布时间】:2022-12-21 16:47:21
【问题描述】:

我可以在 NextJS 中使用 web crypto api 吗?

我试着用

crypto.subtle.digest('SHA-256', data)

但出现错误

ReferenceError: crypto is not defined

【问题讨论】:

    标签: next.js webapi


    【解决方案1】:

    在使用crypto模块之前,只需导入import crypto from "crypto"

    这是crypto的例子

    【讨论】:

    • 不要这样的人。链接也不好
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-16
    • 2015-11-11
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    相关资源
    最近更新 更多