我刚刚在MamP上安装了一个Laravel5项目,我的页面找不到CSS文件.

这是我的应用程序中指向我的css的链接.刀身php文件:

<link href="/css/app.css" rel="stylesheet">

And my .htaccess file has this line:

RewriteBase /laravel-site/laravel-5-app/public/

In the config folder my app.php file contains this:

'url' => 'http://localhost:8888/laravel-site/laravel-5-app/public/',

But when I open up this page: http://localhost:8888/laravel-site/laravel-5-app/public/auth/login and check the developer tools, it is looking for the css file at this location: http://localhost:8888/css/app.css

顺便说一句,如果我转到这个url:http://localhost:8888/laravel-site/laravel-5-app/public/,我会得到正确的欢迎页面.

推荐答案

使用此选项添加assets资源 ,如cssjavascriptimages..变成Blade 锉刀.

F或 CSS,

<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css" >

<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet" type="text/css" >

F或 JS,

<script type="text/javascript" src="{{ asset('js/custom.js') }}"></script>

 <script type="text/javascript" src="{{ URL::asset('js/custom.js') }}"></script>

F或 IMAGES,

{{ asset('img/photo.jpg'); }}

Here is the DOC

Alternatively, if you pulled the composer package illuminate/html which was come as default in laravel 4.2 then you can use like below, In laravel 5. you have to manually pull the package.

{{ HTML::style('css/style.css') }}

Here is an Example.

Laravel相关问答推荐

如何在使用Docker容器部署Laravel 8、9、10时处理SIGTERM信号,特别是与调度程序和工作进程相关的问题?

Laravel 9 中使用 WHERE 子句的列的 SUM

我如何通过 laravel 在高图中针对不同的时间范围进行烛台数据分组

Laravel Eloquent:组合列(或自定义属性)上的 Where 子句

1 子编译中的警告(使用'stats.children:true'和'--stats-children'了解更多详细信息)

向 Laravel 模型查询添加计算字段

Laravel 保存一对多关系

Laravel 5 如何全局设置 Cache-Control HTTP 标头?

laravel 控制器中的全局变量

Laravel 5.3 创建模型返回字段没有默认值

通过单击按钮保存 PhpSpreadSheet

Laravel 表 * 没有名为 * 的列

找不到列:1054字段列表中的未知列0-Laravel-我的代码中的任何地方都没有0列

在表单中添加一对多 - Backpack laravel

中间件中的 Laravel 依赖注入

在 Laravel 5.4 中向多个抄送收件人发送Electron邮件

如何在不使用视图的情况下使用 Laravel 4 发送Electron邮件?

Laravel 错误声明 App\Exceptions\Handler::report(Throwable $exception)

无法捕获 Carbon 抛出的异常

带有 Xdebug 的 Laravel 5 总是抛出The payload is invalid..