[Vuejs]-Vue.js adding a new user to the user array inside json file

1👍

By doing this.users.push({ user: this.user }) you’re actually pushing an object with ‘user’ as key and ‘this.user’ as value:

enter image description here

Do this.users.push(this.user) instead!

0👍

Try to make a deep clone from userData on mount or created, instead of referencing in the "data".

something like this:

data() {
    return {
      users: []
 }
}
mounted() {
  this.users = structuredClone(userData)
}

Let me know if it works.

Leave a comment