我正在使用imgcache缓存cordova应用程序的图像,如果图像已经缓存,则显示缓存的图像。
获取缓存的URL后,当我尝试设置img src属性时,出现以下错误。
不安全:文件系统:http://localhost:8100/temporary/imgcache/108a8c16ec8d04c1d104240c56b97843068a6e08.jpg
net::ERR_UNKNOWN_URL_SCHEME
我尝试调用dom.bypassSecurityTrustUrl来标记URL安全,但我仍然收到错误。
ImgCache.cacheFile(this.image, (cachedFile: string) => {
console.log(this.domSanitizer.bypassSecurityTrustUrl(cachedFile));
this.src = cachedFile;
}, () => {
this.onError();
});
我做错了吗?
答案 0 :(得分:1)
想出了这个问题。我应该将我的domSanitizer返回的值设置为src
this.src = this.domSanitizer.bypassSecurityTrustUrl(cachedFile));