【发布时间】:2015-08-29 14:28:00
【问题描述】:
我无法在我的 Laravel 5 应用程序中为非基础路由链接样式表、脚本和图像。当我访问 example.com/about 脚本和样式表工作正常但如果我访问 example.com/about/something 脚本和样式表链接到 example.com/about/css/style.css 而不是 example.com/css /style.css
我的代码如下:
Routes.php:
Route::get('about/{slug?}', ['as' => 'officerProfile', 'uses' => 'PagesController@about']);
PagesController.php:
public function about($slug = 'president')
{
$officers = Officer::all();
$currentOfficer = Officer::where('slug', $slug)->first();
return view("pages.about", ['title' => $this->makeTitle('Learn About Us')])->with('officers', $officers)->with('currentOfficer', $currentOfficer);
}
layout.blade.php:
{!! HTML::script('https://code.jquery.com/jquery-2.1.4.min.js') !!}
{!! HTML::script('js/skel.min.js') !!}
{!! HTML::script('js/skel-layers.min.js') !!}
{!! HTML::script('js/init.js') !!}
{!! HTML::script('js/scripts.js') !!}
<noscript>
{!! HTML::style('css/skel.css') !!}
{!! HTML::style('css/style.css') !!}
{!! HTML::style('css/style-desktop.css') !!}
</noscript>
由于某种原因,当加载的路由是 example.com/about/something 时,Laravel 认为基本 URL 是 example.com/about。我也尝试过,但它仍然路由到 example.com/about/images/image.jpg 而不是 example.com/images/image.jpg。任何建议将不胜感激。谢谢!
【问题讨论】:
标签: laravel model-view-controller laravel-5