我正在使用 Laravel 5.8。我遇到了一个大问题。 无法读取 CSS 和 Bootstrap。
1.我做了 rm storage 因为我想让 php artisan storage:link 工作。最后我不能。
2.在php artisan serve没有生效后,我在ServeCommand.php中改成了chdir('/');
3.另外我改成了
$this->app->bind('path.public', function() {
return base_path('PATH TO PUBLIC FOLDER');
});
在 AppServiceProvider.php 中
4.现在 php artisan serve 可以正常工作,但无法加载 CSS 和 BootStrap。
这是我的index.blade.php(登陆页面,所有链接都粘贴在这个文件中)
<link href="https://fonts.googleapis.com/css?family=Amatic+SC:400,700|Work+Sans:300,400,700" rel="stylesheet">
<link rel="stylesheet" href="{{asset('external/fonts/icomoon/style.css')}}">
<link rel="stylesheet" href="{{asset('external/css/bootstrap.min.css')}}">
<link rel="stylesheet" href="{{asset('external/css/magnific-popup.css')}}">
<link rel="stylesheet" href="{{asset('external/css/jquery-ui.css')}}">
<link rel="stylesheet" href="{{asset('external/css/owl.carousel.min.css')}}">
<link rel="stylesheet" href="{{asset('external/css/owl.theme.default.min.css')}}">
<link rel="stylesheet" href="{{asset('external/css/bootstrap-datepicker.css')}}">
<link rel="stylesheet" href="{{asset('external/css/animate.css')}}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mediaelement@4.2.7/build/mediaelementplayer.min.css">
<link rel="stylesheet" href="external/fonts/flaticon/font/flaticon.css">
<link rel="stylesheet" href="{{asset('external/css/aos.css')}}">
<link rel="stylesheet" href="{{asset('external/css/style.css')}}">
我在公用文件夹中创建了外部文件夹。
如果有人知道解决方案,请帮助我。
谢谢。
最佳答案
虽然我不知道你到底想实现什么,但我假设你想从 public/external
目录加载文件。
如果你有一个干净的 Laravel 5.8 安装
{{asset('external/css/bootstrap.min.css')
应该开箱即用。所以我应该删除 app->bind
东西并尝试使用
{{asset('external/css/bootstrap.min.css')
关于php - CSS 和 Bootstrap 在 laravel5.8 中不工作。我怎样才能解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56988081/