【问题标题】:Cannot read property 'url' of undefined in Strapi with nuxt,js无法使用 nuxt,js 在 Strapi 中读取未定义的属性“url”
【发布时间】:2021-05-27 04:02:48
【问题描述】:

我收到无法读取未定义错误的属性“url”。 我不明白为什么。 当我换线时 <img :src="'api.example.com' + gallery.Main_picture.url"> 例如{{ gallery.Title }} 一切正常。我做错了什么? 在控制台中,我看到了应有的整个响应。我将不胜感激,并提前感谢您。我将我的 api 域更改为 example.com

<template>
  <v-row no-gutters class="black--text">
    <v-col>
      <img :src="'api.example.com' + gallery.Main_picture.url">
    </v-col>
  </v-row>
</template>

<script>
export default {
  data () {
    return {
      gallery: {}
    }
  },
  async mounted () {
    this.gallery = await this.$strapi.$galleries.findOne(this.$route.params.id)
    console.log(this.gallery.Main_picture.url)
  }
}
</script>

【问题讨论】:

    标签: javascript json vue.js nuxt.js strapi


    【解决方案1】:

    试试这个:

    <img :src="`//api.example.com${gallery.Main_picture.url}`">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-22
      • 2023-02-20
      • 2022-08-15
      • 2019-03-27
      • 2021-07-08
      • 2021-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多