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

151
Views
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
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!