0👍
✅
The code
<div>{{ place.place2.name }}</div>
Yields, as you say, TypeError: Cannot read property 'name' of undefined
because it is trying to get name at a point where .place2
is not yet initialized.
To prevent that from happening, to prevent displaying when it has not yet been initialized, use a conditional (v-if
):
<div v-if="place.place2">{{ place.place2.name }}</div>
Source:stackexchange.com