javascript - 如何在打字稿中使用 javascript 构造函数?
问题描述
我尝试在我的 Typescript 项目中使用 Javascript 库。在 JS 库中,我有一个类(pdfjs-dist),它有一个这样使用的构造函数:
findController = new _pdf_find_controller.PDFFindController({
linkService: pdfLinkService,
eventBus: eventBus
});
我遇到的问题是如何在.d.ts文件中定义 PDFFindController ,所以我可以使用该构造函数? 我试过这样的方法:
class PDFFindController {
constructor(linkService: LinkService, eventBus: EventBus) {}
但到目前为止,我仍然PDFFindController
是undefined,所以我不能使用构造函数。
解决方案
推荐阅读
- powershell - 执行存储在 powershell 对象中的 cmdlet 列表
- javascript - 使用 moment.js 将 UTC 转换为 CST
- reactjs - 如何访问其他组件中的状态?
- python - scrapy没有运行回调函数
- postgresql - 从源代码在 Postgresql 14 中安装 Postgis 时出错
- azure-devops - Azure DevOps 为拉取请求生成工件 ID
- python - 在python中请求URL并制作目录错误
- java - 初学者 Java 编码器试图弄清楚如果问题被回答否如何结束程序
- android - 如何解决android spring框架ResourceAccessException?
- c# - 如何将 sqlite 表数据翻译成印地语或马拉地语等区域语言?