我有一个包含BLOB图像的数组
images[]
0: {id: "1146", image: Blob}
1: {id: "1147", image: Blob}
2: {id: "1148", image: Blob}
3: {id: "1149", image: Blob}
4: {id: "1150", image: Blob}
length: 5
在HTML页面上,我有:
<img [src]="showImage(item.id)" />
我的打字稿代码是:
showImage(itemID) {
let item = [];
item = this.images.filter(x => x.id == itemID);
let image: Blob;
image = item[0].image;
let imageURL = window.URL.createObjectURL(image);
return this._DomSanitizationService.bypassSecurityTrustUrl(imageURL);
}
此代码在Web浏览器上正常工作
但是,当我在DevApp应用程序或模拟器上运行它时,出现此错误
Runtime Error
Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.
离子信息
Ionic Framework: 3.9.2
Ionic App Scripts: 3.2.2
Angular Core: 5.2.11
Angular Compiler CLI: 5.2.11
Node: 10.14.2
有帮助吗?
答案 0 :(得分:1)
经过太多尝试后,问题似乎出在: cordova-plugin-ionic-webview 2.0 +
删除然后添加1.2.1版本解决了我的问题。
ionic cordova plugins rm cordova-plugin-ionic-webview
ionic cordova plugins add cordova-plugin-ionic-webview@1.2.1