I am passing url to local images stored in the ~/assets/img
folder to a Vue3 component, but I am not able to render them by any means.
THIS WORKS
<img
src="~/assets/img/tds_logo.png"
/>
BUT THIS DOES NOT WORK
<img
:src="require(`~/assets/img/` + fileName)"
/>
the last literal fileName
is something I am passing to a Vue component to render the img and I have checked that that is equal to tds_logo.png
in my case.
Instead I get this error:
[nitro] [dev] [unhandledRejection] Error: Cannot find module '~/assets/img/tds_logo.png'
Does anyone know what I am doing wrong?
As per this https://nuxtjs.org/docs/directory-structure/assets/ I shouldn't need to configure anything, right?