使用带变量的控制器路由时出现问题

问题描述 投票:1回答:1

我使用Laravel路线如下。

    Route::get('report/centos7/{id}', 'HomeController@centos7');

然后在Controller中,我使用此代码返回View。

    \View::make('report/centos7/', $id);

发生错误如下。

    InvalidArgumentException in FileViewFinder.php line 137:
    View [report.centos7.] not found.

我把URL称为“mysite / laravelproject / public / report / centos7 / result_target2”

我使用Laravel 5.2第一次在Controller中使用此代码返回\ View :: make('report / centos7 /'。$ id);但是,CSS和JS没有加载。我认为因为“。”这就是我从“改变”的原因。至 ”,”

路线

Route::get('report/centos7/{id}', 'HomeController@centos7');

HomeController的

public function centos7($id)
{
    //
    return \View::make('report/centos7', $id);
}

我已经将“blade.php”动态添加到文件夹视图/ report / centos7 / xxxx.blade.php中。我创建了一个新页面,列出该文件夹中的所有文件,并链接每个文件以刀片格式显示报告。我希望Laravel路由到Controller可以帮助我以刀片格式访问我的报告感谢您的帮助。我是编程语言的新手

更新

我在路线中删除了{id},如下所示

Route::get('report/centos7/{id}', 'HomeController@centos7');

Route::get('report/centos7/', 'HomeController@centos7');

并在HomeController中删除了ID也可以。但是,我仍然希望从Route发送$ id到HomeController当我这样做时,我不知道为什么CSS没有加载到我的刀片php中。请帮忙。

更新(已解决)

感谢上帝每个人如果有人遇到与我相同的问题,我将我的href更改为布局,如下所示。

<link href="{{ URL::asset('theme/vendor/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
laravel-5.2
1个回答
0
投票

主要问题是视图代码中的额外/

\View::make('report/centos7/', $id);

如果您将其更改为以下内容,它应该都能正常工作:

\View::make('report.centos7', $id);

确保您的HTML代码位于resources/views/report/centos7.blade.php文件中。

© www.soinside.com 2019 - 2024. All rights reserved.