If you want to pass a dynamic path to an img
tag using the CLI of Vue (meaning Webpack), here the little gem:
<img :src="require(`@/assets/${myVarOrMethod}`)" />
Happy Vue diving
Spotted a typo or (likely) a grammar error? Send a pull request.
18th July, 2019 1 min. read
If you want to pass a dynamic path to an img
tag using the CLI of Vue (meaning Webpack), here the little gem:
<img :src="require(`@/assets/${myVarOrMethod}`)" />
Happy Vue diving
Spotted a typo or (likely) a grammar error? Send a pull request.