javascript - 无法使用 nuxt,js 在 Strapi 中读取未定义的属性“url”
问题描述
我得到无法读取未定义错误的属性“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>
解决方案
试试这个:
<img :src="`//api.example.com${gallery.Main_picture.url}`">
推荐阅读
- javascript - 如果我要抓取的图像受 cloudflare 保护并给出 1020 错误,有没有办法使用cheerio 抓取网站?
- javascript - 验证 URL | 表格不提交?
- asp.net-mvc - 如何使用操作过滤器读取 .Net 5 Webapi 项目中的请求正文
- google-cloud-storage - 在 Python 中访问 Google 存储桶的问题
- javascript - JS正则表达式匹配相同的字符对
- python-3.x - Python脚本在Google Drive中创建二进制文件而不是文件夹
- html - 为什么“body[attribute="value] element”CSS 选择器不起作用?
- javascript - 获取所有 React 组件的列表
- python - 从服务器下载文件
- javascript - 为什么我们需要在前端表达?