Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
How to use assets folder to load images with dynamic path in Nuxt?

I am using the latest Nuxt 2 version and I want to have my images cached and preload them before animation, static folder doesn't allow me to cache images because this folder is not parsed by webpack, so for that documentation says that I should use assets folder and let webpack parse it for me, the problem is that everything works with static path for the images when I want to add src dynamically my whole path is copied over and it's no longer using webpack for this.

This works:

<img class="lady" src="~/assets/lady/lady_001.png" />

Result: http://localhost:3000/_nuxt/assets/lady/lady_001.png

This not:

<img class="lady" :src="activeImage" alt="" />

Result: http://localhost:3000/~/assets/lady/lady_124.png

...
computed: {
    activeImage() {
      return `~/assets/lady/lady_${this.activeTimeline}.png`;
    },
  },

activeTimeline is just sequence of number from 000 to 180 converted to string. Is there any way to achieve this or I am forced to use some external library for caching static content?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use require when you're dealing with dynamic images in Nuxt.

Assets directory / images link to the docs

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!