export class AttachmentComponent {
imageWidth: number;
imageHeight: number;
ngOnInit() {
this.imgSize(imagePath);
}
getImageSize(url) {
const img = new Image();
img.src = imgurl;
img.onload = (event) => {
const loadedImage: any = event.currentTarget;
const width = loadedImage.width;
const height = loadedImage.height;
}
}
}
在这里,我想填充类的“imageWidth”和“imageHeight”属性,并在getImageSize 的onLoad 中计算宽度和高度。帮助?