在Laravel中更改资产助手URL [英] Change the asset helper url in Laravel
本文介绍了在Laravel中更改资产助手URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认情况下,asset()
或URL::asset()
指向http://my-url/public/
.
是否可以将asset()
的网址更改为http://my-url/public/assets/
?
Is there any way to change the url of asset()
to http://my-url/public/assets/
?
我有很多资产文件,应该在刀片模板中使用它们,并且我不想随时写assets
.
I have many asset files which I should use in my blade templates and I don't want to write assets
any time.
我的意思是在刀片模板中使用asset('js/script.js')
而不是asset('assets/js/scripts.js')
.
I mean use asset('js/script.js')
instead of asset('assets/js/scripts.js')
in my blade templates.
推荐答案
默认情况下,没有任何配置.您可以这样创建自定义函数:
By default, there isn't any configuration for that. You can create your custom function like this:
function my_asset($path, $secure = null){
return asset('/assets/' . trim($path, '/'), $secure);
}
这篇关于在Laravel中更改资产助手URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文