Ionic 4 base64Image不在离子图像中显示,但在img

时间:2019-06-21 08:58:06

标签: ionic4

我无法弄清楚为什么ion-image不显示Plugins.Camera.getPhoto()的base64图像,但是img可以渲染图像:

我的html

<img *ngIf="selectedImage" [src]="selectedImage">
<ion-img
    role="button"
    class="image"
    (click)="onPickImage()"
    [src]="selectedImage"
    *ngIf="selectedImage"
></ion-img>

我的.ts

    Plugins.Camera.getPhoto({
        quality: 50,
        source: CameraSource.Prompt,
        correctOrientation: true,
        height: 320,
        width: 200,
        resultType: CameraResultType.DataUrl
    })
        .then(image => {
            this.selectedImage = this.sanitizer.bypassSecurityTrustResourceUrl(
                image && image.dataUrl
            );
            this.imagePick.emit(this.selectedImage);
        })
        .catch(error => {
            console.log(error);
        });

所以我看到的是:

enter image description here

您可以看到ion-img没有渲染图像

编辑

这是我在selectedImage中获得的值:

  

数据:图像/ JPEG; BASE64,/ 9J / 4AAQSkZJRgABAQAAAQABAAD / 2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkz \ nODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P / 2wBDARESEhgVGC8aGi9jQjhCY2NjY2Nj \ nY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P / wAARCAFAAMgDASIA \ nAhEBAxEB / 8QAGgAAAgMBAQAAAAAAAAAAAAAAAQIAAwQFBv / EAD8QAAEDAgMGAwUECQUAAwAAAAEA \ nAhEDBBIhMQUTIkFRYTJxgRQjkbHBM0Kh0RUkJVJTcoKS8DRiorLhY3Tx / 8QAGQEBAQEBAQEAAAAA \ nAAAAAAAAAAECAwQF / 8QAHREBAQEBAQADAQEAAAAAAAAAAAECETEDBEESIf / aAAwDAQACEQMRAD8A \ n448kfRAJlxdg9FJ7KIqAT2KhPYooFAhPZKT2TlIVRWfJKU7khVQqkoFRUGUZSoogkpdSFFB4gg1D \ nNRAaDyRUVEHCQUykIKC8 + SVrsWaSocII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qEeYC5NZ2NzndTK6F4 / DSdyJ4QueRwqxKrc \ nNFFHKLTLpFQIlQLk6ooiognopPZFRAJ7FQ + SaEIQVnyWbfm5 / ZhZgxkneTMZl2np1WyFTuWBlzcs \ n4bmkCWu6DD006rWPWN + LqtanRuG0KjoqPjCIOcmAkvL52zsGKjj3k / eiI9O6psWHaFs + 5rcd1TcW \ n036YYAIyGWpSbN / au89u97uowfdiZnSOgWc / BnOv6jx4 + L4n U9p6ckNnPdtR72Xx3rWCWjwwfSE1qTd31ayrnHbUcWBmkQYGYz0Xd6CF / tDvaYw71u \ nLDM4fu6 / 0 / irLEyw5aH6BZrt + 4uqlvbgbtvC0HllJz8yVssmjchwEE6 / 56Lnp0y0acipPYoqLDZZ \ n7Fc6ocddx7rpVCGscToAufRBdUkrUSt9qyGhalXRbDVYVBz74zUDZyA / FZhmFdX4nF3dUsylbjJH \ nZGFEXjMqKo6JUGqJQAhcnRFDoioUEHmp6qKQgPxUjuVJRlQKR5rHXt6tXaVB9NmIUi1zswIE / WDI \ n2rHfXT7KpTrUmtLnAtOIGIyK1n1nXiraNP8ASldtSx97gbhf92MzGsd0 + 0v2ru / Yfe7qcf3YmI1j \ noVLn9h4fZePfTi3mcRpER1RuQdiNabXjFbJxqZxGkRHUrs5JtEnaraYsTvRTkvHhidNY6FC6 / W7G \ njZW / HcUYxs0iBBzOWqlwf0IGG149 / wCI1M9NIiOqlU + wUWbQpZ17iMTX + EYuIwNdUDCix1viI46T \ nQw9iAAR8ZV9tTNOnB / zn9UlEY7R7udR2M + bmgn8Sr2aHzXKuuTKIwostKLt0UDB1yVFqyXBW3uYa \ nE1mzRaiNjBASXDsNJ3U5K6ICy3JkETpkkSszswVmOT46rZUbhIA5hZKninotIBCiMqIjo8kOSaNE \ nCFzdEChGaiJGaBYRUIkZoYR0CAogIADojA6KCQqbisy1dSuHhxDSQQ3XMf8A4r4HQKm8ZRNEGu2a \ nbXAu10mOXmrPUvjJbtGzXuvn529cQxrc3CcxM9h1Ut2jZtQ3z87esIY1ubhOYnloEBWoPqOZdVmP \ nsGj3QBzB5ZDiyEjNBlak + o5l5UY6xb9i0OBI / dybxaTqu7ie2qs2Xir1pcy6h1PAJIGuc + YRpEbH \ nqVH3QxGuZbu84jWZjqEjKlo9zm3z2uoMMW4BkhvfDnpGqFKtSrT + l6jHx9lhcDHXwemqDfRpll毫米

0 个答案:

没有答案