2017-09-15 55 views
1

我无法弄清楚如何从base64字符串创建ImageSourceNativeScript中base64字符串的ImageSource

let source = new ImageSource(); source.fromBase64('b64strhere').then(..);

在这方面的参数如下承诺通过

是一个布尔值,我不知道什么是应该代表。之后的ImageSource在Android和iOS上均为null。

我在这里错过了什么?

回答

0

我加载它,并把在图像元素是这样的:

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)

+1

显然,我的错误是在有以base64字符串的MIME类型,它是返回false。将您标记为答案,因为它是关于如何使用ImageSource类的良好代码示例。 – greedz