Laravel:在刀片页面中使用资产方法有什么优势? [英] Laravel: What's the advantage of using the asset method in blade pages?
本文介绍了Laravel:在刀片页面中使用资产方法有什么优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一些laravel示例中,我看到资产被这样称呼:
In some laravel examples I've seen assets being called like this:
<link rel="icon" type="image/png" href="{{ asset('icons/favicon-32x32.png') }}" sizes="32x32">
使用该方法相对于这样做有什么好处?
What is the advantage of using that method as opposed to doing this?
<link rel="icon" type="image/png" href="icons/favicon-32x32.png" sizes="32x32">
推荐答案
如果执行后者,则当您使用任何包含正斜杠的URL时,这些URL将不起作用.例如.如果您在主页上,则不使用asset
似乎可以正常工作,但是如果您使用的是/search/results
或其他任何内容,则URL将会不正确(因为它将查找/search/icons/favicon-32x32.png
).
If you do the latter, the URLs will not work when you're on any URL that includes a forward slash. E.g. not using asset
will appear to work fine if you're on the homepage, but if you were on /search/results
or whatever, the URLs won't be correct (as it'll be looking for /search/icons/favicon-32x32.png
).
这篇关于Laravel:在刀片页面中使用资产方法有什么优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文