Laravel 错误异常路由未定义

我正在开始一个新项目 laravel make, 由两页我创建目录中的页面组成
app/view

, 这是我的文件
route.php

:


Route::get/'/', function//
{
return View::make/'hello'/;
}/;

Route::get/'welcome', function//
{
return View::make/'welcome'/;
}/;

Route::any/'signup', function//
{
return View::make/'signup'/;
}/;


我可以通过单击浏览器中的链接以及运行时访问注册页面 artisan routes, 他向我展示了我创建的路线。

welcome.blade.php

, 当我添加字符串时


{{link_to_route/'signup'/}}


并重新启动页面我有此错误


ErrorException
Route [signup] not defined. /View: C:\wamp\www\atot\app\views\welcome.blade.php/


我怎么解决这个问题?
已邀请:

龙天

赞同来自:

相反:


Route::any/'signup', [
'as' => 'signup',
function// {
return View::make/'signup'/;
}
]/;


你的问题是你没有使用命名的路线。

如果您愿意,您可以在此阅读更多信息:
http://laravel.com/docs/routing#named-routes

窦买办

赞同来自:

link_to_route是一种生成的方法 url 对于指定
http://laravel.com/docs/routing#named-routes
, 因此,要使它起作用,可以调用每个路线,然后它将工作


link_to_route/'route.name', $title, $parameters = array//, $attributes = array///;


在更新中 routes.php 下一个


Route::get/'/', array/'as'=>'home', function//
{
return View::make/'hello'/;
}//;

Route::get/'welcome', array/'as'=>'welcome', function//
{
return View::make/'welcome'/;
}//;

Route::any/'signup', array/'as'=>'signup', function//
{
return View::make/'signup'/;
}//;


然后,您可以生成以下路由:


{{link_to_route/'home'/}}
{{link_to_route/'welcome'/}}
{{link_to_route/'signup'/}}

莫问

赞同来自:

您必须使用:


{{ link_to/'signup'/ }}


或使用名称声明路由


Route::any/'signup', array/'as' => 'signup', function//
{
// ...
}//;


http://laravel.com/docs/helpers
link_to_route

它仅适用于名称的路由,该路由接受第一个参数中的路由名称。

要回复问题请先登录注册