CSS和JS未在Laravel模板中加载

时间:2018-11-27 04:12:04

标签: laravel laravel-5 laravel-blade

我是Laravel的新手,想加载模板。但是,当我加载它时,仅显示基于HTML的数据,而CSS / JS文件未加载。我所有的CSS和JS文件都在/ public文件夹中。这个问题有什么解决办法吗?

CSS

<link rel="stylesheet" href="{{ asset('css/backend_css/bootstrap.min') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/bootstrap-responsive.min') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/fullcalendar') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/matrix-style') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/matrix-media') }}" />
<link href="font-awesome/{{ asset('css/fonts/backend_fonts/css/fonts-awesome.css') }}" 
  rel="stylesheet" />

JS

<script src="{{ asset('js/backend_js/excanvas.min.js') }}"></script> 
<script src="{{ asset('js/backend_js/jquery.min.js') }}"></script> 
<script src="{{ asset('js/backend_js/jquery.ui.custom.js') }}"></script> 
<script src="{{ asset('js/backend_js/bootstrap.min.js') }}"></script> 
<script src="{{ asset('js/backend_js/jquery.flot.min.js') }}"></script> 
<script src="{{ asset('js/backend_js/jquery.flot.resize.min.js') }}"></script> 
<script src="{{ asset('js/backend_js/jquery.peity.min.js') }}"></script> 

Here是我的文件夹的屏幕快照的链接。

以下是在Google Chrome浏览器中以开发人员模式显示的链接。

href="http://localhost/laravel/ecom2/public/css/backend_css/bootstrap.min"
href="http://localhost/laravel/ecom2/public/css/backend_css/bootstrap-responsive.min"
href="http://localhost/laravel/ecom2/public/css/backend_css/fullcalendar"
src="http://localhost/laravel/ecom2/public/js/backend_js/matrix.interface.js"
src="http://localhost/laravel/ecom2/public/js/backend_js/matrix.chat.js"
src="http://localhost/laravel/ecom2/public/js/backend_js/jquery.validate.js"

5 个答案:

答案 0 :(得分:0)

您的CSS,JS路径当前无效

您没有在CSS,JS文件中附加extensions

此外,您还应该与工匠一起运行项目

php artisan serve

然后转到localhost:8000

答案 1 :(得分:0)

尝试

URL::asset(‘your resource here’)

代替

asset(‘your resource here’)

答案 2 :(得分:0)

<link rel="stylesheet" href="{{ asset('css/backend_css/bootstrap.min') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/bootstrap-responsive.min') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/fullcalendar') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/matrix-style') }}" />
<link rel="stylesheet" href="{{ asset('css/backend_css/matrix-media') }}" />

这里有一个错误。您的css文件必须以.css结尾,如下所示:

<link rel="stylesheet" href="{{ asset('css/backend_css/bootstrap.min.css') }}" />

还要检查您的js文件

答案 3 :(得分:0)

这是错误,请使用正确的CSS扩展名

 <link rel="stylesheet" href="{{ asset('css/backend_css/bootstrap.min.css') }}" 

答案 4 :(得分:0)

确保您运行

 php artisan serve

并修复您的.css扩展名