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

204
Views
Local images not loading in Vue

I'm trying to build an image gallery using Vue.js and local images are not loading. I have the src attributes set in the data attribute and can only seem to load images from external sources. Example:

data() {

        return {
            images: [
              "../assets/images/photos/bathroom/bathroom-1.png",
              "https://i.natgeofe.com/n/46b07b5e-1264-42e1-ae4b-8a021226e2d0/domestic-cat_thumb_square.jpg",
            ],
        };
    },

With the rest of my code to scroll through the gallery, the first image doesn't load though the second image does. I figure it's something to with the the way Vue compiles everything, as I can display the image statically with a regular tag and setting the src manually.

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

0

Wrap any relative path in require().
In your case:

export default {
  data: () => ({
    images: [
      require("../assets/images/photos/bathroom/bathroom-1.png"),
      "https://i.natgeofe.com/n/46b07b5e-1264-42e1-ae4b-8a021226e2d0/domestic-cat_thumb_square.jpg"
    ]
  })
}
   

Documentation: Vue Loader.

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!