我对Angular 6比较陌生。 我试图在我的Angular 6应用程序中包含cornerstonejs。但是我遇到了这个错误:
错误TS7016:找不到模块'cornerstone-core / dist / cornerstone.js'的声明文件
我已使用npm install cornerstone-core
安装了corestone-core。
有人可以指出为什么此代码不起作用吗?
component.ts
import { Component, ElementRef, ViewChild, OnInit, AfterViewInit } from '@angular/core';
import * as cornerstone from 'cornerstone-core/dist/cornerstone.js';
@Component({
selector: 'image-stack-viewer',
templateUrl: './image-stack-viewer.component.html',
styleUrls: ['./image-stack-viewer.component.css']
})
export class ImageStackViewerComponent implements OnInit, AfterViewInit {
@ViewChild('testpod') canvasDiv: ElementRef;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
const imageId = ''//my-mage-url;
var element = this.canvasDiv;
cornerstone.enable(this.canvasDiv);
cornerstone.loadImage(imageId).then(function (image:any) {
cornerstone.displayImage(element, image);
});
}
}
HTML
<div #testpod width="500" height="400"></div>
答案 0 :(得分:0)
您必须像这样声明基石:
declare const cornerstone;
看看此存储库以查找示例:https://github.com/avatsaev/angular-cornerstone-example