[Vuejs]-Add & Edit in same Vuejs Page

1๐Ÿ‘

โœ…

I believe the problem is that you are passing new Object() to your editItem method. Iโ€™m assuming that you assign that value SelectedUnit in that method, which is causing the error.

The problem is that this sets the nested object address to undefined. So when you try and read addressLine1 from an undefined object, it will throw an error.

I suggest setting SelectedUnit to a blank version of itself inside the edit method. Something like this.

this.SelectedUnit = {
  address: {
    addressLine1: '',
    ...
  },
  bedrooms: '',
  ...
}
๐Ÿ‘คjrend

Leave a comment