0
votes

I'm pretty new to Vue, what I'm doing now is the following.

I receive an Item prop in my component, I spread this Item prop out over a Form data object that's defined in my component (as to have reactivity)

data() {
  return {
    form: {}
  }
mounted () {
  this.form = {
    ...this.item,
    translations: { ...this.item.translations }
  }
},

Now my local form data holds the information, including reactive translations, right?

Next thing I try to do is filter this data, but then it's failing me. If I console.log(this.form). It is an Observable (see screenshot)

enter image description here

Is there a way to filter, reduce, map on this 'Observable'? Am I doing 'reactivity' the right way?

2
Can you show the code that filters the data? How is it "failing" you? An error message? Or unexpected behavior?tony19

2 Answers

1
votes

Try clone/deepClone, before assigning the item to this.form.

0
votes

You can access props from data() directly.

data() {
  return {
    form: {
      ...this.item,
      translations: { ...this.item.translations }
    }
  }
},
computed: {
   getForm() {
     // use filter/map method here, e.g.
     // return this.form.filter((item) => { ... })
   }
}