[英]Vue Lazy Loading banners
I Have 5 banners on a page that are shown or hide depending on a user click selection.我在页面上有 5 个横幅,根据用户点击选择显示或隐藏。
At this point the banners data comes from an API and I am iterating a banner component for every banner entry I have on the API, Any idea on how i can get the image downloaded only after a user click?此时横幅数据来自 API,我正在为 API 上的每个横幅条目迭代横幅组件,知道如何仅在用户点击后下载图像吗? I have tried lazy-loading native behavior, but the images load at the beguinning because all of them appears at first scroll, I show or hide images with user click.
我尝试过延迟加载本机行为,但图像在开始时加载,因为它们都出现在第一次滚动时,我通过用户点击显示或隐藏图像。
<banner-base
v-for="banner in entry.banners"
:key="banner.id"
:slug-ficha="slugSelected"
:promo-selected="promoSelected"
:banner-id="banner.id"
/>
You can use v-show
directive on the img
element and it will show only when the banner is clicked.您可以在
img
元素上使用v-show
指令,它只会在单击横幅时显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.