3

The problem is simple: I would like to display an image from an absolute path in vuetify with the v-img tag but it is not showing.

I have already tried doing it with :src="require('path/to/img')" but then an error comes saying "This dependency was not found"

<v-img src="src/assets/project_atv_logo.jpg" class="mb-4" contain height="128" ></v-img> 

The file is stored under src/assets folder. I am using a mac pc if it matters.

3 Answers 3

3

try to use

<v-img :src="require('@/assets/project_atv_logo.jpg')" class="mb-4" contain height="128" ></v-img> 
Sign up to request clarification or add additional context in comments.

1 Comment

This dependency was not found: * @src/assets/project_atv_logo.jpg in ./node_modules/cache-loader/dist/cjs.js?{"cacheDirector y":"node_modules/.cache/vue-loader","cacheIdentifier":"24ddd4d4-vue-loader-template"}!./node_ modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vuetify-l oader/lib/loader.js!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-load er/lib??vue-loader-options!./src/components/HelloWorld.vue?vue&type=template&id=469af010& To install it, you can run: npm install --save @src/assets/project_atv_logo.jpg
1

This worked for me:

<script setup lang="ts"> import logo from '@/assets/logos/banana.svg'; </script> <template> <v-img height="150" :src='logo' /> </template> 

Comments

0

For the Vite environment, the solution is to use new URL('[path_to_image]', import.meta.url).href

See my answer here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.