Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
Dynamic src attributes no longer working with require()

Haven't touched Vue in a while, now I'm building a <HeroImage> component in Vue and Vuetify which takes an src attributes, put the image, and combine it a certain way with the slot and other props.

Usually, the answer is wrapping the src string in a request(). But now it throws this message at compile time:

Critical dependency: the request of a dependency is an expression

Here's what I'm trying to do:

<!--
 src/views/Home.vue
-->
<template>
  <!-- This does not work -->
  <HeroImage src="@/assets/hero-image.png" />

  <!-- As comparison, this somehow works -->
  <img :src="require('@/assets/hero-image.png')" />
</template>

<script>
import HeroImage from "@/components/HeroImage"
export default {
  components: { HeroImage }
}
</script>
<!--
  src/components/HeroImage.vue
-->
<template>
  <img alt="Hero Image" class="align-center justify-center" :src="require(src)" />
</template>

<script>
export default {
  name: "HeroImage",
  props: {
    src: String
  }
}
</script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda