[Vuejs]-Object doesn't get updated but gets added

-2👍

this.selectedProp = { ...this.selected};
// It should be written in the watch function


  watch: {
    selected: {
      handler(val) {
        if (val) {
          this.selectedProp = JSON.parse(JSON.stringify(val)) // or cloneDeep
        }
      },
      immediate: true,
      deep: true,
    },
  },

I didn’t see your $emit function
Can you post it?

Leave a comment