I've got basic vue props and data:
props: ['person', 'type']
data() {
return {
offer: {
type: 'basic',
person: 'nurse',
...
How can I make my data react to props change? For example if prop person
will be 'physican'
I want my data offer.person = 'physician'
. Oherwise if props value will be empty, I want to have default value of offer.person
.
How is the easiest way to achieve this? I tried watchers, computed, but none of them seems to work.
edit: I wrote something like this:
basicComputed(){
this.offer.person = this.person
this.offer.type = this.type
},
and then in template:
<template>
<div>
{{basicComputed}}
</div>
</template>
It works, but it seems that it is not a perfect solution. Is there a better way to do it?