字节数组图像 src nativescript

byte array image src nativescript

在 nativescript(with angular)中,有什么方法可以根据 Web api 调用的响应设置图像的 src returns 图像作为字节 array/base64? 文档不多,我需要从一个简单的示例中查看 html 和 .ts 文件,我现在没有代码可以粘贴到这里。

您需要先创建 ImageSource 形式的 base64 字符串,然后将该 imageSource 分配给 Image Native Element。

let imageSource = new ImageSource();
let loadedSource64 = imageSource.loadFromBase64(BASE_64_STRING_FROM_API_CALL);
if (loadedSource64 ) {
    let image= <Image>this.imageElement.nativeElement;
    image.imageSource = this.imageSource;
}