我得到了一个 Laravel 元素,我设法下载它的配置并在 php artisanserve 上启动它。
当我在 localhost:8000 上打开它时,它会打开,但只打开它的 html 部分。
CSS 文件似乎没有加载。
我们是否需要在我的环境中使用 Composer 安装某种软件包。
让 CSS 正常工作。
公共(public)文件夹在 laravel 元素中看起来像这样。
backend favicon.ico front images index.html index.php js robots.txt sql vendor
web.config
最佳答案
Laravel 提供了一个辅助函数 asset()
,它可以为您的 Assets 生成 URL。您可以在 Blade 语法中使用它。
将您的 css、js 文件放在 public
文件夹中。例如 css 文件,将其放在:
../public/bootstrap/css/bootstrap.min.css
在您的 Blade 中,您可以从 header 访问此文件,如下所示:
<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" >
希望这有帮助
关于php - 我的新 Laravel 元素中的 Css 和 Js 文件未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62419556/