【发布时间】:2021-10-31 21:19:39
【问题描述】:
我想要达到的目标:
我正在使用什么:
Laravel、InertiaJS、Vue 3 我的代码是:
PostLayout.vue: 【问题讨论】:
从 Post.vue 中的动态链接显示一张图片,它遵循 PostLayout.vue 的布局
在 PostLayout.vue 中,我有一个名为 postFeaturedImage 的
Post.vue:<template>
<PostLayout>
<template #postfeaturedImage>
<!-- Here I want to display the image -->
</template>
</PostLayout>
</template>
<script>
import PostLayout from '@/Layouts/PostLayout'
export default {
data() {
return {
featured_image: ''
}
},
components: {
PostLayout,
},
props: {
post: Object /* Passed the prop from Controller */
},
mounted () {
this.featured_image = this.post.featured_image
}
}
</script>
<template>
<slot name="postfeaturedImage" :bgImage="bgImage">
<div :style="`background-image:url(${bgImage}); height: 75vh;`"></div>
</slot>
</template>
<script>
export default {
}
</script>
我已经删除了所有不相关的代码。我是 Vue 3 和 Inertia 的初学者,需要帮助!
标签: javascript vue.js vuejs3 inertiajs