laravel中图像的动态路由 [英] dynamic routing for images in laravel

查看:212
本文介绍了laravel中图像的动态路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在laravel中处理图像或某些功能非常重要...例如,我有一个仪表板页面具有@yield('content')...在仪表板中有一些图像,例如logo.png/背景-pattern.png& ……当我得到他们的网址时,例如

I have a big deal with image or some features routing in laravel ... for example I have a dashboard page that has @yield('content') ... in dashboard there are some images like logo.png / background-pattern.png & ... . when I get a url for them for example

src="assets/img/logo.png" 

.像

Route::get('/reports' ...)

但不适用于

Route::get('/report/crete' ...)

页面.对于创建页面,我应该给一个src之类的

page . for create page I should give a src like

 src="../assets/img/logo.png"

我如何动态地将URL赋予图像?

how can I give the url dynamically to images ??

抱歉,这是一个愚蠢的问题,我是laravel的新手. 谢谢你的时间

sorry if it's stupid question I'm newbie in laravel . thanks for time

推荐答案

您可以使用:

asset('assets/img/logo.png')

它将生成整个网址.

另一种方法是在HTML文档的开头部分设置基本href:

Another method is setting base href in head section of your HTML document:

<base href="http://yoururl.com/" />

(末尾带有斜杠)

并在任何地方使用:

src="assets/img/logo.png"

这篇关于laravel中图像的动态路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆