I
I
Ilya-19792020-02-28 18:35:50
JavaScript
Ilya-1979, 2020-02-28 18:35:50

Can't see images in vuetifyjs carousel. How to write paths correctly?

<template>
           <v-carousel hide-delimiters>
             <v-carousel-item
             v-for="(item,i) in items"
              :key="i"
              :src="item.src"
               ></v-carousel-item>
            </v-carousel>
       </template>
      <script>
       export default {
         data () {
             return {
             items: [
            {
                    src: '@/assets/img1.jpg',
            },
           {
                  src: '@/assets/img2.jpg',
           },

          ],
       }
     },
   }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel T, 2020-02-28
@Yorik

The easiest way is to put images in public (or static) and access them from the root /public/img1.jpg

K
Kutuzov_ska, 2020-03-03
@Kutuzov_ska

If still relevant, you can try to do this:

import image1 from '../assets/img1.jpg'; // Путь прямой, не через @
import image2 from '../assets/img1.jpg';

export default {
  data: () => ({
    items: [image1, image2]
  })
}

Try like this. But it will be more conceptual to set up nginx / apache, distribute statics and pictures through it, and pass just paths to img;
<v-carousel-item
             v-for="(item,i) in items"
              :key="i"
              :src=" `http://***/img${i}.jpg` "
               ></v-carousel-item>
            </v-carousel>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question