我正在输出一个项目的 RadListView,每个项目都有一个 base64 格式的图像,但我无法显示它们。
在我的组件循环中
let base64ImageSource = new ImageSource;
base64ImageSource = fromBase64(returned_expenses[i].receipt_data);
在我的模板中
<Image row="0" col="1" [src]="base64ImageSource" horizontalAlignment="right" width="100" height="100" stretch="none"></Image>
而且没有图像。
我看过下面的代码
this.imageSource = new ImageSource();
var loadedBase64 = this.imageSource.loadFromBase64(MY_BASE_64_STRING_PREVIOUSLY_SAVED);
console.log(loadedBase64);
if (loadedBase64) {
let photo = <Image>this.photoImage.nativeElement;
photo.imageSource = this.imageSource;
this.photo = photo;
}
但是我不知道这条线是干什么的
let photo = <Image>this.photoImage.nativeElement;
即。 photoImage 被声明为什么?
感谢您的指导!
最佳答案
在您的示例代码中,photoImage
可能是对元素的引用,可能正在使用 ViewChild
HTML
....
<Image #photoImage></Image>
...
TS
@ViewChild("photoImage") photoImage: ElementRef;
关于angular - 将 base64 图像数据数组显示为图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54445828/