[Vuejs]-What to do when the variable that enters :src becomes null?

0๐Ÿ‘

โœ…

You can always use the ternary if inside the :src

Example:

<v-img
  :src="product.eyecatch ? product.eyecatch : ''"
  :lazy-src="product.eyecatch"
></v-img>

Or use the

v-if
v-else

when declaring the v-img

0๐Ÿ‘

If you add a v-if, you shound not get this error anymore, as the component wonโ€™t get rendered if the product.eyecatch is null

<v-img
  v-if="product.eyecatch"
  :src="product.eyecatch"
  :lazy-src="product.eyecatch"
></v-img>

Leave a comment