I have this simplified avatar component:
<template>
<img :src="src">
</template>
<script>
export default {
name: 'Avatar',
props: {
src: {
type: String,
default: '/static/avatar-default.png'
}
}
}
</script>
Let's say I retrieve some user data from my API and does not contain an avatar url. In this case, I want this component to use the default value, but it only works on transmission undefined
, but is undefined
not valid in JSON, so I cannot return this from the API response.
Is there a way to implement what I want by going to null
or is there a better way to handle this?
source
share