Laravel:在刀片页面中使用资产方法有什么优势?

编程入门 行业动态 更新时间:2024-10-25 14:31:36
本文介绍了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:在刀片页面中使用资产方法有什么优势?

本文发布于:2023-10-17 10:23:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500637.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   刀片   资产   优势   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!