I have a component with props like that:
props: {
data: Object
},
data display: {{ data.a.b.c.d.title }}
I want to create a variable like: d = this.data.a.b.c.d.
data display: {{ d.title }}
What is the best practice to create this variable?
CodePudding user response:
Use a computed prop, like this...
props: {
data: Object
},
computed: {
d() {
return this.data.a.b.c.d;
}
},
<!-- in the markup -->
<p>{{ d.title }}</p>