Ionic framework 不允许加载本地资源:file:///storage/emulated/0/Download/1533311989863.png 爱奥尼亚3(安卓)
我在从本地电话或sd卡存储加载图像时在ionic 3(android)中出错Ionic framework 不允许加载本地资源:file:///storage/emulated/0/Download/1533311989863.png 爱奥尼亚3(安卓),ionic-framework,ionic3,Ionic Framework,Ionic3,我在从本地电话或sd卡存储加载图像时在ionic 3(android)中出错 path="file:///storage/emulated/0/Download/1533311989863.png" <img [src]="path" > </img> 输出:- Not allowed to load local resource: file:///storage/emulated/0/Download/1533311989863.png 使用ionic本机文件插件
path="file:///storage/emulated/0/Download/1533311989863.png"
<img [src]="path" > </img>
输出:-
Not allowed to load local resource: file:///storage/emulated/0/Download/1533311989863.png
使用ionic本机文件插件从文件系统读取为base64:
File.readAsDataURL(cordova.file.dataDirectory, fileUrl).then(imageBase64 => {
self.urlToShow = imageBase64;
});
清理base64 url:
get imageURLSanitized() {
return this.sanitizer.bypassSecurityTrustUrl(this.urlToShow);
}
在HTML中,使用经过消毒的url作为[src]
<img [src]=“imageURLSanitized”>
<img [src]=“imageURLSanitized”>