Vue/Vuetify 和绑定 carousel img src 与不显示图像的方法

D M*_*art 2 vue.js vuetify.js

开始一些 Vue/Vuetify,我想要实现的是从 v-carousel 的定义方法绑定图像 src,但我出现空白。

循环似乎可以工作,我正确地使用了该方法,并从该函数中记录了我希望返回的值,但它只是没有将其显示为图像的来源。

  <div v-for="(post, index) in posts" :key="post.images+'_'+index">
    <v-carousel-item>
      <img v-bind:src="getImage(index)" alt="">
    </v-carousel-item>
  </div>
  </v-carousel>
Run Code Online (Sandbox Code Playgroud)

对于我有的方法:

getImage (index) {
  butter.content.retrieve(['cardimages'])
    .then((resp) => {
      console.log(resp.data.data.cardimages[index]['images_' + index])
      return resp.data.data.cardimages[index]['images_' + index]
    })
}
Run Code Online (Sandbox Code Playgroud)

在页面 src 我看到:

img data-v-656039f0="" alt=""
Run Code Online (Sandbox Code Playgroud)

并且不确定这意味着什么。根据如何做到这一点,我离题很远吗?我错过了什么?

小智 8

我只是遇到了同样的问题并 src: require('../assets/hh-home.jpg') 为我工作