[Vuejs]-How to pass images has props in a vue js component (Configured with vite cause require doesnt work in vite)

-1👍

Just import the asset in <script> and use the variable as the src attribute.

From the docs

Importing a static asset will return the resolved public URL when it is served:

<script setup>
import RoomImage from "../../assets/images/room3.jpg";
</script>

<template>
  <rooms-card 
    :roomImage="RoomImage" 
    roomType="Duplex Room" 
    roomDescription="Sami double bed 1 guest room 3 windows" 
    roomPrice="$50/night"
  />
</template>

Leave a comment