NativeScript中base64字符串的ImageSource
问题描述:
我无法弄清楚如何从base64字符串创建ImageSource。NativeScript中base64字符串的ImageSource
let source = new ImageSource(); source.fromBase64('b64strhere').then(..);
是一个布尔值,我不知道什么是应该代表。之后的ImageSource在Android和iOS上均为null。
我在这里错过了什么?
答
我加载它,并把在图像元素是这样的:
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;
}
(NS 3.1)
显然,我的错误是在有以base64字符串的MIME类型,它是返回false。将您标记为答案,因为它是关于如何使用ImageSource类的良好代码示例。 – greedz