angular - 在 typescript 文件中导入 'dom-autoscroller' 会产生 'Can not find module'

标签 angular typescript import autoscroll

我正在尝试在我的 angular4/typescript(v2.5) 项目中使用“dom-autoscroller”和 dragula。我已经成功安装了“dom-autoscroller”npm 包,但是当我尝试使用以下行导入 AutoScrollerFactory 或 autoScroll 函数时,出现“找不到模块”错误:

  • 从“dom-autoscroller/dist/bundle.es”导入 AutoScrollerFactory;
  • 从“dom-autoscroller”导入 * 作为 autoScroll;

需要注意的是,我使用的是 VS2015,当鼠标悬停在“dom-autoscroller”文本上方时会显示错误。

任何帮助将不胜感激

最佳答案

最后,我通过定义 dom-autoscroller 所需功能的类型版本找到了解决问题的方法。以下是步骤:
1. 将“node_modules/dom-autoscroller/dist/dom-autoscroller.js”脚本添加到您的.html/.aspx 文件
2. 在任何您想使用它的地方声明 autoScroll 函数,如下所示:

declare function autoScroll(elements: any, options: any): any;

关于angular - 在 typescript 文件中导入 'dom-autoscroller' 会产生 'Can not find module',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46065471/

相关文章:

Angular 2 - 模型更改后 View 不更新

angular - 将 Spring boot 服务器和 Angular CLI 应用程序集成到单个可执行文件中

asp.net - 使用 Asp.Net 的微服务

angular - 构造函数中设置的变量不可见

java - 使用 UJMP 库时如何从文件导入/导出矩阵?

java - 在 Eclipse 中自定义组织导入

html - 如何打开/关闭 Angular Material 菜单

javascript - 我可以将获取值类型的对象的模式应用于类的非静态成员吗​​?

javascript - 如何实现一个没有名字的接口(interface)成员?

C# Excel 从 CSV 导入数据到 Excel