vue-lazyload icon indicating copy to clipboard operation
vue-lazyload copied to clipboard

image not update while loop re-render

Open theara72 opened this issue 6 years ago • 11 comments

hi ! i have problem image not update while i remove item.data re-render is okay but image isn't render at all.if you have solution that would be big help for most user.Please check my code

<div v-if="items.length > 0" class="sticky-container bg-shade pb-3" :class="{'show': triggerCompare}">
        <label class="bg-default txt-white" @click="triggerCompare = !triggerCompare">COMPARE</label>
        <div class="list-container container-fluid py-3">
            <div v-for="(item,index) in items" :key="index" class="item mb-3">
                <img v-if="item.photo" :src="domainPhotoName+pathImageName+item.photo"/>
                <img v-else src="http://localhost:8081/static/images/image_unavailable.png"/>
                <i class="fas fa-times" @click="items.splice(index,1)"></i>
                <div class="des txt-white p-2" :class="{'bg-default-glass':(item.type == 'Rent'),'bg-buy-glass':(item.type == 'Buy')}">
                    <h5>{{ item.title }}</h5>
                    <strong>{{ item.price }}</strong>
                </div>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row">
                <div class="col-6"><button class="flat-button bg-second txt-white mt-0" v-if="listItem.length >= 2" @click="checkCompare">Compare</button></div>
                <div class="col-6"><button class="flat-button bg-rb txt-white mt-0" @click="$emit('update:items', [])">Clear</button></div>
            </div>    
        </div>
    </div>

theara72 avatar Sep 05 '18 01:09 theara72

same issue here, even when out of a loop, when the data changes the src, the image does not reload

darkylmnx avatar Sep 11 '18 01:09 darkylmnx

Same here.

cerw avatar Sep 13 '18 08:09 cerw

Yes please fix this! There is no reactivity in the loop.

asch3ron avatar Sep 23 '18 00:09 asch3ron

same...not updates image src when loop data updated

synergist23 avatar Sep 23 '18 06:09 synergist23

#273 加一个key 就解决了

lilywang711 avatar Sep 28 '18 03:09 lilywang711

I've found https://github.com/alexjoverm/v-lazy-image to be a good replacement that does have reactivity of the image src

richstandbrook avatar Sep 28 '18 08:09 richstandbrook

using unique :key solved my problem.. note. don't use index as key

rpahlevy avatar Oct 16 '18 10:10 rpahlevy

using unique :key solved my problem.. note. don't use index as key

This solved my issue, thanks!

sstottelaar avatar Dec 02 '18 20:12 sstottelaar

I was having some trouble when data changes, but using v-lazy directive on <img> tag and a unique key had solved my problem! In my case i have a v-for loop to render the images and in this loop i have a condition to check if the image was already selected (like a wish list), but if i toggle select/deselect, the plugin triggers load event again. The data change thats was causing this problem is a computed data that returns if is selected or not. Its fixed now, thanks ❤️

webdesignmf avatar Apr 10 '19 13:04 webdesignmf

Hey guys, I had the same issue where my src was sometimes updating and then it just wouldn't update. My image was not in a loop.

Upon reading the docs back on the main github page, there's actually a single lined section... at the very bottom which is not in the table of contents:

Dynamic Switching Pictures

They authors should really put that somewhere near the top or at least update the Table of Contents... since it is so important. Hope this helps someone.

matthewyeow avatar May 03 '19 02:05 matthewyeow

:key didn't work for me. I've had image in a separate component, not used it as <img/> but instead <ImgComponent/> and i've tried both: setting :key to the <img/> tag and to the <ImgComponent/>. Nothing worked for me. setting observer: true did solve the issue. Though scrolling the page became a bit slower.

Vue.use(VueLazyload, { observer: true });

tylik1 avatar Jan 08 '21 14:01 tylik1