代码之家  ›  专栏  ›  技术社区  ›  skxc

Nativescript中base64字符串的ImageSource

  •  1
  • skxc  · 技术社区  · 7 年前

    ImageSource 来自base64字符串。

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

    我错过了什么?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Cesar    7 年前

    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)