[Vuejs]-Can a prop be reactive?

0👍

I might not be understanding 100% but I think this is what you’re after.

I typically use a computed property with a getter and a setter in this case.

props: {
  someProp: String,
},
computed: {
  somePropLocal: {
    get () {
      return this.someProp
    },
    set (value) {
      this.$emit('input', value)
    },
  },
}

This way you can do this freely and the proper value will be emitted.

this.somePropLocal = 'Whatever'

Also, somePropLocal will be updated if the parent changes it directly as well.

Leave a comment