[Vuejs]-Vue: Ignore property until axios then

0👍

You could use the conditional ternary operator to check if the key is in the object first and only if it is, use it’s value, e.g.:

{{'title' in page_data ? page_data.title : '' }}

Otherwise, you could use Lodash’s _.get method, e.g.:

{{ _.get(page_data, 'title', '') }}

_.get is also useful for when you want to get a “deep” property, e.g.:

{{ _.get(page_data, 'article.title', '') }}

0👍

You can try using “v-if” before you render {{page_data.title}} E.g

<p v-if="page_data.title"> {{page_data.title}} </p>

Leave a comment