jsmmth / vue-loop

Infinite content loop for Vue
820 stars 37 forks source link

How can I load dynamic data #8

Closed coding-sunshine closed 7 years ago

coding-sunshine commented 7 years ago

Sorry if I am being stupid here, but I want to load dynamic data from the server on a scroll. How can I call it?

jsmmth commented 7 years ago

Have you used VueJS before?

you'd simply have a variable which is an array on the data. Then use aJax or Axios to get a response back from an api endpoint or something. Then simply update the variable on data with the response and loop through them within vue-loop tags.

<vue-loop>
    <div v-for="item in array" class="item">
             [dynamic content] {{ item.name }} etc
    </div>
</vue-loop>

or with php you could just do:

<vue-loop>
    <?php foreach($array as $item) { ?>
        <div class="item">
             <?php echo $item->name; ?>
        </div>
    <?php } ?>
</vue-loop>

Hope this helps you understand it a little more. Let me know if theres any issues. 😊

coding-sunshine commented 7 years ago

thanks for the response. I am still learning vuejs so :)

jsmmth commented 7 years ago

no worries @coding-sunshine have you checked out http://vuecasts.com/ I recommend it.