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

221
Views
Cómo importar URL de imágenes dentro de un archivo javascript

Así que copié un código en reaccionar a javascript nativo. Tengo una carpeta llamada imgs esta carpeta contiene todas las imágenes y un archivo index.js que se ve así.

 export { default as img1 } from "./one.jpg"; export { default as img2 } from "./two.jpg"; export { default as img3 } from "./three.jpg"; export { default as img4 } from "./four.jpg"; export { default as img5 } from "./five.jpg";

Ahora traté de importar estas imágenes a otro archivo como este

 import { img1, img2, img3, img4, img5 } from "./imgs";

y me da error en mi consola ingrese la descripción de la imagen aquí

 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

esto funciona de maravilla cuando lo usé en CRA pero no funciona aquí. Qué me estoy perdiendo

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

0

En mis proyectos, creo un archivo y coloco todas las llamadas de imagen en él.

 const image1=requre("../location image ") export { image1 }

Y en el archivo donde quiero usar las fotos

 import {image1} from "../images file" <Image source={image1} />
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!