Laravel路线在引导按钮

Jef*_*eyR 4 twitter-bootstrap laravel

我想创建一个链接到route:normindex的按钮

这种打击似乎不起作用.

 <button href={{ HTML::link('normindex')}} type="button" class="btn btn-default">Left</button>
 <button href="normindex" type="button" class="btn btn-default">Left</button>
Run Code Online (Sandbox Code Playgroud)

以下内容确实有效但生成链接,而不是按钮.

{{ HTML::link('normindex','Left')}}

有谁有想法吗?

Ana*_*nam 8

请尝试以下方法:

<a href="{{ URL::route('normindex') }}" class="btn btn-default"> Norm Index </a>
Run Code Online (Sandbox Code Playgroud)

要么

link_to_route('normindex', 'Norm Index', null, array('class' => 'btn btn-default'));
Run Code Online (Sandbox Code Playgroud)


Man*_*era 5

好吧,它们不起作用,因为HTML::link()将输出完整的HTML链接,而您的第二次尝试仅在href属性中使用纯文本,因此Laravel无法知道它需要在其中包含某些内容。


您可以尝试以下方法:

 <button href="{{ route('normindex') }}" type="button" class="btn btn-default">Left</button>
Run Code Online (Sandbox Code Playgroud)

route()助手将打印您传递给它的路线的URL。这将在routes.php文件中需要一个命名路由,例如:

Route::get('your-path', array('as' => 'normindex', function()
{
   // do stuff
}));
Run Code Online (Sandbox Code Playgroud)