[Vuejs]-Vue.js state is not updating: Resolved

0👍

I don’t know Laravel, but I think this is the problematic part:

this.items = data.data;

You need to place your data into items with a loop. Otherwise, the data in items is not reactive.

Like this (running a for loop, you also iterate with forEach):

this.items.splice(0); // just in case you want to replace already existing data

for (let i = 0, l = data.data.length; i < l; i++) {
  this.items.push(data.data[i]);
}

I haven’t checked the code, but I think you get the idea;

0👍

Try to use created() lifecycle hook instead of mounted()

https://v2.vuejs.org/v2/api/#Options-Lifecycle-Hooks

Leave a comment