【发布时间】:2019-11-15 02:35:44
【问题描述】:
我正在使用 Ionic 4 和 Angular 7 开发 PWA。
如果存在网络摄像头,我需要访问它,然后在画布中呈现。 在这个过程中,我使用 ImageCapture (https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture)。
let constrains =
{
audio:false,
video:
{
frameRate: { ideal: 60, min: 30 },
facingMode: { ideal: "user" },
width: { exact: 626 },
height: { exact: 720 },
}
}
navigator.mediaDevices.getUserMedia(constrains).then(mediaStream =>
{
this.Webcam.nativeElement.srcObject = mediaStream;
this.Webcam.nativeElement.play();
const track = mediaStream.getVideoTracks()[0];
let ic:ImageCapture = new ImageCapture(track);
return this.ImageCapture.getPhotoCapabilities();
});
我收到一个错误,因为 TypeScript 对 ImageCapture 一无所知,所以我安装了类型,将它们添加到我的 package.json 中:
npm install --save-dev @types/w3c-image-capture
当使用“ionic serve”或“ionic build --prod”构建应用程序时,出现以下错误:
src/app/pages/photoframe/photoframe-take/photoframe-take.page.ts(26,22) 中的错误:错误 TS2304:找不到名称“ImageCapture”。 src/app/pages/photoframe/photoframe-take/photoframe-take.page.ts(117,28):错误 TS2663:找不到名称“ImageCapture”。您是指实例成员“this.ImageCapture”吗?
如果我调试 ImageCapture 有价值的应用程序,那么这只是我构建问题。
如何从我的构建中删除此错误?
【问题讨论】:
标签: angular typescript typescript-typings image-capture