[英]Laravel and Vue: How do I get images from my public folder in a Vue component?
I am trying to get a logo image from my public folder in my laravel and Vue application.我正在尝试从我的 Laravel 和 Vue 应用程序的公共文件夹中获取徽标图像。 The file is called
index.vue
and have the following structure:该文件名为
index.vue
并具有以下结构:
<template>
<div>
<div class="header-container">
<div class="header-content">
<div class="logo-container">
<img :src="'/public/images/logo/black.png'" alt="logo">
</div>
</div>
</div>
<!-- Tell Vue where to render components -->
<router-view></router-view>
</div>
</template>
Here is the file structure and you can see that file exists and the path is correct:这是文件结构,您可以看到该文件存在且路径正确:
But when I switch back to the view it looks like this:但是当我切换回视图时,它看起来像这样:
I have also tried to call it the way I would in a blade template using {{ asset() }}
, but this doesn't work and gives me a compiler error.我还尝试使用
{{ asset() }}
在刀片模板中调用它,但这不起作用并给我一个编译器错误。
How do I get this image to load in my Vue file?如何让这张图片加载到我的 Vue 文件中?
Not sure about vue + laravel.不确定 vue + laravel。 But, since its a relative path I dont think you need to bind anything.
但是,由于它是一个相对路径,我认为您不需要绑定任何东西。
<img src="/images/logo/black.png" alt="logo">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.