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

260
Views
la imagen no carga la configuración del script vuejs

Estoy tratando de cargar imágenes dinámicamente en un componente secundario, pero la imagen no se carga.

Esto es lo que probé:

el básico: src = "imagePath" no se carga

require ya no está disponible por lo que no funciona

import( ../${imagePath} ) devuelve una Promesa indefinida

Aquí está mi código:

Componente principal

 <script setup lang="ts"> import TheProject from './utils/TheProject.vue'; const projects = [ { idProject: 1, title: "title", desc: "desc", imagePath: "../path/..", cardColor: "C4F6DE" }, ] </script> <template> <div v-for="project in projects"> <TheProject :idProject="project.idProject" :title="project.title" :desc="project.desc" :imagePath="project.imagePath" :cardColor="project.cardColor" /> </div> </template>

Componente hijo

 <script setup lang="ts"> import { onMounted } from 'vue'; const props = defineProps({ idProject: Number, title: String, desc: String, imagePath: String, cardColor: String }) </script> <template> <img :src="props.imagePath" /> </template>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Supongo que estás usando Vite:

Intente envolver la URL con una new URL('path_here', import.meta.url).href

 <script setup> const imagePath = new URL('./logo.png', import.meta.url).href </script> <template> <img :src="imagePath" /> </template>

Vite docs: nueva URL

Además, hay un problema abierto sobre los activos con URL dinámica si desea profundizar más.

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!