[Vuejs]-Nuxt.js/Vue.js dynamic images is not working

0👍

In your template, change:

<img :src="getImgUrl(project.p_img_path)" alt="project cover image">

To:

<img :src="require(`../assets/${project.p_img_path}`)" alt="project cover image">

You shouldn’t need a method to return the path as a string, just use a template literal as above.

Ps. This assumes project.p_img_path = img/project_img/filename.jpg, so adjust as necessary.

0👍

The solution is that I had to put all the images inside the assets folder directly. Thank you all for your time.

Leave a comment