Angular 2-导入html2canvas [英] Angular 2 - Import html2canvas
本文介绍了Angular 2-导入html2canvas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用npm install html2canvas --save
在angular 2
项目上安装了html2canvas
.如果现在转到任何文件并写入import * as html2canvas from 'html2canvas'
,则会显示错误:
I have installed html2canvas
on my angular 2
project using npm install html2canvas --save
. If I now go to any file and write import * as html2canvas from 'html2canvas'
it gives the error:
Cannot find module 'html2canvas'
我的软件包文件如下:
{
...
"scripts": {
...
},
"dependencies": {
...
"html2canvas": "^0.5.0-beta4",
...
},
"devDependencies": {
...
}
}
我要导入html2canvas
的文件是:
import { Injectable } from '@angular/core';
import * as jsPDF from 'jspdf';
import * as html2canvas from 'html2canvas';
@Injectable ()
export class pdfGeneratorService {
...
}
推荐答案
由于Angular2使用打字稿,因此您需要为该模块安装打字稿定义文件.
Since Angular2 uses typescript, you need to install the typescript definition files for that module.
可以从@types
安装(如果存在).如果没有,则可以创建自己的定义文件并将其包含在项目中.
It can be installed from @types
(if it exists). If it doesn't you can create your own definition file and include it in your project.
这篇关于Angular 2-导入html2canvas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文