【发布时间】:2021-07-10 19:45:48
【问题描述】:
所以我正在使用 spatie 媒体库,我可以将图像上传到存储和数据库。我正在尝试在一个 vue 组件中显示多个图像。这是我的控制器。
public function showHotelPhoto($id)
{
$hotel = Hotel::first()->getFirstMedia('images')->getUrl();
return Inertia::render('AdminHotelPhoto', [
'data' => $hotel,
]);
}
这是我的 vue 组件,我已经成功获取了图片 URL,但只有一个图片 URL。在我的情况下,我需要显示数据库中的所有媒体。
<template>
<breeze-authenticated-layout>
<template #header>
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Foto Hotel
</h2>
</template>
{{ data }}
<img v-bind:src="image">
{{ test }}
</breeze-authenticated-layout>
</template>
<script>
import BreezeAuthenticatedLayout from '@/Layouts/Authenticated'
export default {
components: {
BreezeAuthenticatedLayout,
},
props: ['data', 'test'],
data () {
return {
image: this.data
}
},
}
</script>
【问题讨论】:
-
您可以添加更多上下文吗?您是否收到错误/您可以显示不起作用的代码吗?您是否尝试在 vue 组件中显示图像?
-
是的,兄弟,我正在尝试在 Vue 组件中显示图像,并且我已经编辑了问题兄弟,所以我想获取所有图像并将它们显示在 Vue 组件中。提前致谢
标签: laravel vue.js filepond inertiajs