无法在离子项目中的主页上加载图像

问题描述

我主页上的图像加载不到一秒钟,然后消失了。在页面的其余部分,其加载正确。以前我遇到了CORS错误,因此我在index.html文件的下面添加了行

  <meta http-equiv="Content-Security-Policy" content="img-src 'self' https://example.com/ data: cdvfile://* file:///*; default-src 'self' https://example.com/ ws://localhost:35729 data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' localhost:35729 'unsafe-eval' 'unsafe-inline';">

仅在延迟加载我的图像时发生。代码看起来像这样:

@Component({
  selector: 'lazy-img',template: `
  <div text-center [ngClass]="{ 'placeholder': placeholderActive }">
    <img [inputSrc]="inputSrc" [ngStyle]="style" lazy-load (loaded)="placeholderActive = false"/>
  </div>
  `
})
export class LazyImgComponent {

  @Input() inputSrc: string;
  @Input() imgStyle:any={}; 
  public placeholderActive: boolean = true;
}

经过几次阅读,我发现那里 我的网络视图版本"cordova-plugin-ionic-webview": "^1.1.19"有问题 加载页面时,我的控制台出现以下错误

E/Capacitor/Console: File: http://localhost/ - Line 0 - Msg: Not allowed to load local resource: file:///storage/emulated/0/Android/data/com.educationtoppers.lms/cache/IMG_20200813_152359.jpg?1597561207374

I/Capacitor/Console: File: http://localhost/build/main.js - Line 13720 - Msg: fetching complete..
D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.ico
V/Capacitor/Plugin: To native (Cordova plugin): callbackId: File854190565,service: File,action: requestAllFileSystems,actionArgs: []
I/Capacitor/Console: File: http://localhost/build/main.js - Line 13720 - Msg: fetching complete..
I/Capacitor/Console: File: http://localhost/build/main.js - Line 13114 - Msg: Shall track featured = 1
I/Capacitor/Console: File: http://localhost/build/main.js - Line 13075 - Msg: Popular track comp 1
I/Capacitor/Console: File: http://localhost/build/vendor.js - Line 220605 - Msg: INFO: LocalFileSystem opened
V/Capacitor/Plugin: To native (Cordova plugin): callbackId: File854190566,action: getDirectory,actionArgs: ["cdvfile:\/\/localhost\/persistent\/","imgcache",{"create":true,"exclusive":false}]
I/Capacitor/Console: File: http://localhost/build/vendor.js - Line 220605 - Msg: INFO: Local cache folder opened: cdvfile://localhost/persistent/imgcache/
V/Capacitor/Plugin: To native (Cordova plugin): callbackId: File854190567,action: getFile,actionArgs: ["cdvfile:\/\/localhost\/persistent\/imgcache\/",".nomedia","exclusive":false}]
I/Capacitor/Console: File: http://localhost/build/vendor.js - Line 220605 - Msg: INFO: .nomedia file created.
I/Capacitor/Console: File: http://localhost/build/main.js - Line 13114 - Msg: Shall track featured = 1
I/Capacitor/Console: File: http://localhost/build/main.js - Line 13075 - Msg: Popular track comp 1
V/Capacitor/Plugin: To native (Cordova plugin): callbackId: File854190568,actionArgs: 

["cdvfile:\/\/localhost\/persistent\/","imgcache\/83854f34cb0009ecc0fa9e1e958ddc1ffcbebb10.jpg",{"create":false}]

V/Capacitor/Plugin: To native (Cordova plugin): callbackId: File854190569,actionArgs: 
["cdvfile:\/\/localhost\/persistent\/","imgcache\/22e76d75a5648c67795c282ec8bd82960e37ac42.jpg",{"create":false}]
W/Capacitor/Console: File: http://localhost/ - Line 0 - Msg: A cookie associated with a cross-site resource at http://example.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

V/Capacitor/Plugin: To native (Cordova plugin): callbackId: File854190598,"imgcache\/4304ac2f55b0c74bf518b9986ac841bfdea02b42.jpg",{"create":false}]

我觉得我的index.html文件的meta标记中缺少某些内容。

在本地主机上本地运行时,在我的浏览器上运行正常。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...