0👍
The comments give you some idea to fix the issue. and here is why:
when the page/component loading, if you are using data
to render the template, it will render the template with the init data you defined, that’s null
for posts
in your code.
to fix this, either you put some default data for your data
prop in your Vue component. like
data() {
return {
posts:[{image:{url: "../assets/logo.png"}}],
}
}
or using if
or ?:
in the template.
I personally like my way, this way lets you know what’s your data struct is. make your code clear and easy to debug.
- [Vuejs]-Need Help in Router Guard Navigation in Vuejs
- [Vuejs]-Creating a search bar using Laravel and Vue JS (Vuetify Framework) – resulting in error 'Cannot read property 'protocol' of undefined'
Source:stackexchange.com