简体   繁体   English

隐藏时阻止图像上传

[英]prevent image's upload when it's hidden

I'm working on responsive web application, and when I use mobile devices I have noticed that the hiding images are uploaded in the network of the browser.我正在开发响应式 web 应用程序,当我使用移动设备时,我注意到隐藏图像已上传到浏览器的网络中。 Therefore is not a good thing for the performance of the application and i want to stop upload these images when im using mobile device.因此对于应用程序的性能来说不是一件好事,我想在使用移动设备时停止上传这些图像。 In my HTML I have used a css style for each device and variables to display the image in normal browser and I hide it in mobile device (using *ngIf) but it doesn't prevent it from uploading the image.在我的 HTML 中,我为每个设备和变量使用了 css 样式以在普通浏览器中显示图像,并将其隐藏在移动设备中(使用 *ngIf),但它不会阻止它上传图像。 can you please help to solve this optimization issue and what is the best way to do it.你能帮忙解决这个优化问题吗?最好的方法是什么。 I'm working with Angular 8 and i don't want to use jQuery.我正在使用 Angular 8,我不想使用 jQuery。

Thanks in advance提前致谢

loadIt() {
    if(imageIsInFront) {
    mustBeLoaded = true;
    }
}

<div *ngFor="let img of images, let i=index">
  <img *ngIf="mustBeLoaded" (load)="loadIt()" [src]="img">
</div>

not tested未测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM