ts中引入js报错
一、 无法找到模块“@/xxx/xxx”的声明文件。“xxx.js”隐式拥有 “any” 类型。
解决办法:
使用 require
引用
const {
encryptionJump,decryptJump } = require("@/utils/rsa")
二、ts中使用全局js方法报错
解决办法
- 申明多个挂载到全局
declare const window: Window & {
SG_sm2Encrypt: any,SG_sm2Decrypt: any,format:any };
使用时用window
window.SG_sm2Encrypt(data, pubkeyHex);
- 单个申明
declare var SG_sm2Encrypt:(data:any,hex:any)=>any
使用时正常使用即可
SG_sm2Encrypt(data, pubkeyHex)
可
SG_sm2Encrypt(data, pubkeyHex)