【问题标题】:How to find/import javascript module from Angular 2 app如何从 Angular 2 应用程序中查找/导入 javascript 模块
【发布时间】:2017-06-15 18:51:41
【问题描述】:

我将 dom-to-image 添加到我的 package.json 并在我尝试使用它的文件中,所以我有以下行。

import domtoimage from 'dom-to-image';

我在这一行得到Cannot find module 'dom-to-image',所以我不确定如何导入javascript库。

在我的 node_modules 目录中,我有库。

【问题讨论】:

  • 你首先必须在imports中的app.module中注册模块,签名为import {domtoimage} from 'dom-to-imange',然后你就可以使用这个库了

标签: angular typescript import


【解决方案1】:

确保您运行新的 npm 安装,然后语法应该会选择它。

请注意,当您执行 document.getbyId 时,请确保在其前面加上正确的标签,即:document.getElement...

【讨论】:

    猜你喜欢
    • 2017-07-30
    • 1970-01-01
    • 2020-12-14
    • 2016-12-09
    • 2017-05-02
    • 2017-01-13
    • 2019-06-11
    • 2018-03-10
    • 2023-03-16
    相关资源
    最近更新 更多