Laravel - asset() 函数运行不正常
Laravel - asset() function noy working well
我的 laravel 项目有问题。
在我的 link.blade.php 文件中我有:
<!-- Bootstrap core CSS -->
<link href="{!! asset(css/bootstrap.min.css) !!}" rel="stylesheet">
<link href="{!! asset(css/theme.css) !!}" rel="stylesheet">
<link href="{!! asset(css/bootstrap-reset.css) !!}" rel="stylesheet">
当 运行 我的服务器时,我得到:
Use of undefined constant css - assumed 'css' (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php) (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php) (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php) (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php)
编译器似乎无法获取我的 css/bootstrap.min.css(位于 public 目录)。
当我删除这个 css 文件后,它会移动到第二个文件,依此类推(也是 js 文件)。
Public 目录:
Link
我该怎么办,求助!!
您需要在字符串周围加上引号:
<link href="{!! asset('css/bootstrap.min.css') !!}" rel="stylesheet">
您需要保留 css 和这样的 JS 文件
了解更多详情 https://laracasts.com/discuss/channels/general-discussion/laravels-5-csslink?page=1
从你的文件结构中你只需要直接引用它而不需要asset()
函数
会这样
<link href="/css/bootstrap.min.css" rel="stylesheet">
<link href="/css/theme.css" rel="stylesheet">
<link href="/css/bootstrap-reset.css" rel="stylesheet">
关闭功能资产
我的 laravel 项目有问题。
在我的 link.blade.php 文件中我有:
<!-- Bootstrap core CSS -->
<link href="{!! asset(css/bootstrap.min.css) !!}" rel="stylesheet">
<link href="{!! asset(css/theme.css) !!}" rel="stylesheet">
<link href="{!! asset(css/bootstrap-reset.css) !!}" rel="stylesheet">
当 运行 我的服务器时,我得到:
Use of undefined constant css - assumed 'css' (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php) (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php) (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php) (View:
/home/ubuntu/workspace/resources/views/partials/links.blade.php)
编译器似乎无法获取我的 css/bootstrap.min.css(位于 public 目录)。
当我删除这个 css 文件后,它会移动到第二个文件,依此类推(也是 js 文件)。
Public 目录: Link
我该怎么办,求助!!
您需要在字符串周围加上引号:
<link href="{!! asset('css/bootstrap.min.css') !!}" rel="stylesheet">
您需要保留 css 和这样的 JS 文件
了解更多详情 https://laracasts.com/discuss/channels/general-discussion/laravels-5-csslink?page=1
从你的文件结构中你只需要直接引用它而不需要asset()
函数
会这样
<link href="/css/bootstrap.min.css" rel="stylesheet">
<link href="/css/theme.css" rel="stylesheet">
<link href="/css/bootstrap-reset.css" rel="stylesheet">
关闭功能资产