【发布时间】:2019-02-11 20:51:12
【问题描述】:
我正在尝试将 camanjs 与 angular 6 一起使用。当 npm 上没有类型时,如何添加 js lib 并将其与 angular 一起使用。我遵循很多步骤
使用 npm 安装 caman
使用其在节点模块中的路径将其作为脚本添加到 angular.json
像
这样将它导入到组件中
import * as Caman from 'path to caman in node module'
- 在 AfterViewInit 中我像使用它
ngAfterViewInit() { Caman('#image-id', function () { this.brightness(10); this.contrast(20); }); }
但是当启动服务器时出现此错误
【问题讨论】:
-
我按照这些步骤操作并在控制台“caman 未定义”中给我一个错误
-
请考虑创建一个堆栈闪电战,以便有人可以调查。
-
感谢@SiddharthAjmera,您的回答非常有用。
标签: angular typescript types camanjs