跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • vue + ts 中 import crypto from ‘crypto’ 失败,提示 Cannot find module ‘crypto’ or its corresponding type declarations.
未分類
18 10 月 2020

vue + ts 中 import crypto from ‘crypto’ 失败,提示 Cannot find module ‘crypto’ or its corresponding type declarations.

vue + ts 中 import crypto from ‘crypto’ 失败,提示 Cannot find module ‘crypto’ or its corresponding type declarations.

資深大佬 : Nicolay 2

请问大家该怎么办呢,我在 es6 的项目中这样写是没有问题的,
大佬有話說 (5)

  • 主 資深大佬 : Nicolay

    package.json 中是这样写的 ,crypto-js 和 crypto 都需要用,虽然我不太懂二者的区别,不过 import cryptoJs from ‘crypto-js’ 没有问题,
    “dependencies”: {
    “@types/crypto-js”: “^3.1.47”,
    “@types/echarts”: “^4.8.1”,
    “axios”: “^0.19.0”,
    “crypto”: “^1.0.1”,
    “crypto-js”: “^4.0.0”,
    },

  • 資深大佬 : Timefly

    缺少类型声明文件吧,或许还要装一个 @types/crypto,先去 npm 上看看有没有

  • 主 資深大佬 : Nicolay

    @Timefly 这个的确没有,

  • 資深大佬 : mxT52CRuqR6o5

    用啥打包的,crypto 是 node 自带模块,打包器不帮你打包浏览器环境是运行不了的

  • 主 資深大佬 : Nicolay

    @mxT52CRuqR6o5 webpack

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具