[Vuejs]-Add a loader everytime computed method is called Vuejs

0👍

template

 <div v-if="load" class="lds-dual-ring"></div>
 <div v-else>
    <div class="col-xl-3 col-lg-4 col-md-6 col-sm-6 col-9" v-for="product in computedProducts">
        <img :src="product.photo.url" alt="" class="main_img">
    
            <p>{{ product.name }}</p> 
            <div class="hover">
                <p>{{ product.name }}</p>
                <a :href="product.document.url"><img src="img/pdf_icon_white.svg" alt=""></a>
                <p>Factsheet als PDF downloaden</p>
           </div>
        </div>
    </div>

add function to methods (part of code)

methods : {
    
    filteredProducts : function() {
    
    // some code
    
    this.load =  // true or // false
    
    }
 }

Leave a comment