Objects in Vue
Now let's say that we have an object written to data:
data() {
return {
obj: {a: 1, b: 2, c: 3},
}
}
Let's print the contents of this object to the screen:
<template>
{{ obj.a }}
{{ obj.b }}
{{ obj.c }}
</template>
Or you can use an alternative method:
<template>
{{ obj['a'] }}
{{ obj['b'] }}
{{ obj['c'] }}
</template>
Let data store the following object:
data() {
return {
obj: {x: 1, y: 2, z: 3},
}
}
Display the sum of the elements of this object.