[Vuejs]-Show recently added record at top in vuejs

0👍

basically if I’m correct what you want is to push new images to the images array, for this just use unshift()

something like this


this.images.unshift('url_or_info_of_the_new_image')

0👍

Here, you do have an example of code showing you how you could achieve this.
https://codesandbox.io/s/gracious-tree-nig54?file=/src/App.vue

Essentially, the most interesting part is this.initialArray = [this.newValue, ...this.initialArray].

Also, depends on what you’ve tried until now but keep in mind the few caveats JavaScript does have with VueJS v2: https://v2.vuejs.org/v2/guide/reactivity.html#For-Arrays

Leave a comment