php - CSS not loaded with net::ERR_ABORTED 404 error
问题描述
When I updated from Symfony 3.4 to 4.0 and displayed it in a browser, the following error appeared.
Symfony/assets are also installed,
I tried the code below but it didn't work.
Is there anything else you can think of?
Directory
src/
└ Resources/
┝ public/css/style.css
└ view/layout.html.twg
Try Code
<link rel="stylesheet" href="{{absolute_url(asset('css/style.css'))}}">
<link rel="stylesheet" href="{{ asset('css/style.css') }}">
<link rel="stylesheet" href="../public/css/style.css">
Version
Symfony 4.0.15
PHP 7.3
symfony/asset 4.0.15
解决方案
I moved the css directory from within the Resources/public directory to inside the public/ directory in the project and the code below fixed the issue.
<link rel="stylesheet" href="{{ asset('/css/style.css') }}">
推荐阅读
- javascript - 无法删除数组中的所有 Boolean == false
- sql - SQL 查找 Orders 表中每一行的下一个订单日期
- typescript - 基于提供的参数的返回字典键的打字稿类型推断
- python - 将十六进制转换为浮点数后结果错误
- java - 比较方法(compareTo)在不同的JVM中返回不同的结果
- pointers - 如何在 Fortran 中的下一个内存地址分配/获取变量的值
- c# - 在命令行中关闭 IIS Express
- android - 如何在 Android 上创建半可拖动的回收视图?
- neo4j - Neo4j Desktop db 升级到 3.5 后无法启动
- r - 如何对 sf 对象使用“反连接” - 不在多边形内的子集点