Using dynamic path in Vue CLI

• 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