php Laravel 5 链接 css 资产的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27727744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 issues with linking css assets
提问by Sojan V Jose
am currently trying to port my laravel 4 application to laravel 5 . i have added "illuminate/html": "5.*"
to composer and also the facade and service providers to config. i was using the following syntax to link to my css files
我目前正在尝试将我的 laravel 4 应用程序移植到 laravel 5 。我已经添加"illuminate/html": "5.*"
到 composer 以及外观和服务提供者来配置。我使用以下语法链接到我的 css 文件
{{ HTML::style('css/bootstrap.min.css') }}
{{ HTML::style('css/style.css') }}
but in laravel 5 , my views output is all broken , with the page displaying like the below screenshot .
但是在 Laravel 5 中,我的视图输出全部损坏,页面显示如下面的屏幕截图。
what could i be missing here ? is there any changes to the blade syntax in laravel 5 ?
我会在这里错过什么?laravel 5 中的刀片语法有什么变化吗?
回答by Sojan V Jose
found the answer here on this threadand here.
on the second thread Taylor Otwell gives the answer himself . In laravel 5 , the laravel 4 default syntax {{ code }}
, will escape the data output . if you want unescaped html data, you have to use the new syntax
在此线程和此处找到了答案。在第二个线程中,Taylor Otwell 自己给出了答案。在 laravel 5 中,laravel 4 默认语法{{ code }}
将转义数据输出。如果你想要非转义的 html 数据,你必须使用新的语法
{!! HTML::style('css/style.css') !!}
if you want to revert to previous syntax you can use
如果你想恢复到以前的语法,你可以使用
Blade::setRawTags('{{', '}}');
回答by Yousof K.
- Check if the assets are there, and are being linked properly.
- check permission and set
chmod
to 777 (Unix). - If that doesn't work, use
<link rel="stylesheet" type="text/css" href="{{asset('relative/to/public/folder.css')}}" >
manually.
- 检查资产是否在那里,并且是否正确链接。
- 检查权限并设置
chmod
为 777 (Unix)。 - 如果这不起作用,请
<link rel="stylesheet" type="text/css" href="{{asset('relative/to/public/folder.css')}}" >
手动使用。
回答by Ritchie
<link href="{{ asset("assets/css/style.css") }}" rel="stylesheet">
回答by jaahvicky
Change your code to the below
将您的代码更改为以下
{!! Html::style( asset('css/bootstrap.min.css')) !!}
{!! Html::style( asset('css/style.css')) !!}
回答by Anshu Shekhar
If you want to use plain HTML then you can also use it like this-
如果你想使用纯 HTML,那么你也可以像这样使用它 -
<link rel="stylesheet" href="/css/style.css">