【发布时间】:2017-02-18 01:12:13
【问题描述】:
这是我的路线文件...
Route::group(['middleware' => ['auth']], function(){ Route::get('/profile/{username}', 'ProfileControllers@getProfile'); });“ProfileControllers”是这个...
命名空间 App\Http\Controllers; 使用数据库; 使用应用\用户; 使用 Illuminate\Http\Request; 类 ProfileControllers 扩展控制器 { 公共函数 getProfile($username) { $user = DB::table('users')->where('username','=', $username)->get(); 返回视图('web.profile'); } }这是视图文件...
@extends('布局') @section('内容') 这是你的个人资料 @停止而Layout文件的头部是这个……
链接 rel="stylesheet" type="text/css" href="css/bootstrap.min.css" 链接 rel="stylesheet" type="text/css" href="css/app.css"当我转到 url "localhost:8000/profile/username" 时,会显示一个没有任何 CSS 网页的丑陋 html.... 当我从路由文件中删除“/{username}”,并将其设为“/profile/username”并转到“localhost:8000/profile/username”(并删除 $username 部分表单控制器),然后 css 和引导加载完美....
这里发生了什么?
【问题讨论】:
-
当你转到“localhost:800/profile/username”时。用户名是否存在于您的数据库中?或者你只是输入一个随机的用户名?
-
是的,Salam 兄弟,用户名存在.....现在,另一个问题发生了......如果将路由设置为“/profile/foo”并转到 localhost:8000/profile/ foo,css 没有加载.....
-
在我看来,CSS 路径不是绝对的,而是相对于 URL。打开开发人员工具并检查被调用的路径并修复它。另外,不确定是否是这种情况,但在使用
base标签时要小心。 -
你说得对,米尔兹。这就是问题所在。这个小虫子毁了我一整天...
-
很高兴您解决了这个问题。我将投票结束这个问题,因为一个无法再复制的问题或一个简单的印刷错误。
标签: php mysql twitter-bootstrap laravel laravel-5.3