我在 .css 下有一个基本的 .css 文件app/Resources/public/css/
。每个文件都应该包含它,所以我想把它放在布局文件中。如果有的话,我还想包含其他 css 文件。这是我的布局的样子:
<!DOCTYPE>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Title{% endblock %}</title>
<link rel="stylesheet" type="text/css" charset="UTF-8" media="all" href="{{ asset('css/base.css') }}">
{% block stylesheets %}{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
{% block javascripts %}{% endblock %}
</body>
</html>
据我所知,它应该包括我的基本 .css 文件和我在样式表块中使用的任何其他 .css 文件。
但是它不起作用。它生成css文件的相对url,但它只是没有打开。将此 url 键入浏览器 ( localhost/project/web/css/base.css
) 会产生一些未捕获的异常。
Fatal error: Uncaught exception 'Symfony\Component\Routing\Exception\ResourceNotFoundException' in C:\xampp\htdocs\MyFitnessManager\app\cache\prod\appProdUrlMatcher.php:33 Stack trace: #0 C:\xampp\htdocs\MyFitnessManager\app\cache\prod\classes.php(1207): appProdUrlMatcher->match('/css/base.css') #1 C:\xampp\htdocs\MyFitnessManager\app\cache\prod\classes.php(1872): Symfony\Component\Routing\Router->match('/css/base.css') #2 [internal function]: Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #3 C:\xampp\htdocs\MyFitnessManager\app\cache\prod\classes.php(1667): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #4 C:\xampp\htdocs\MyFitnessManager\app\cache\prod\classes.php(1600): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #5 C:\xampp\htdocs\MyFitnessManager\app\cache\prod\classes.php(1764): Symfony\Comp in C:\xampp\htdocs\MyFitnessManager\app\cache\prod\classes.php on line 1883
这是怎么回事?