在 Laravel 中,我有一个名为 ZOEKEN 的链接,它转到“zoekenindex”。有效
<li> {{HTML::link('zoekenindex','ZOEKEN')}}</li>
但是我想要一个按钮而不是链接:
<button href="{{ route('zoekenindeze') }}" type="button" class="btn btn-default">Left</button>
此输出:“无法为命名路由“zoekenindex”生成 URL,因为该路由不存在。”
我不明白为什么,因为当我使用链接代码时路由有效。
有人知道为什么这是可能的吗?
最佳答案
Laravel 在你的路由文件中找不到任何名为 zoekenindex
的名称路由。
创建名称路由:
Route::get('zoekenindex', array('as' => 'zoekenindex', 'uses' => 'yourController@index'))
您的按钮:bootstrap 默认会创建按钮。不用担心链接。
<a href="{{ URL::route('zoekenindex') }}" class="btn btn-default">Left</a>
Laravel 助手:
{{ link_to_route('zoekenindex', 'Left', null, array('class' => 'btn btn-default')) }}
或者,如果您不喜欢创建名称路由,请使用以下内容:
<a href="{{ URL::to('zoekenindex') }}" class="btn btn-default">Left</a>
Laravel 助手:
{{ link_to('zoekenindex', 'Left', array('class' => 'btn btn-default')) }}
关于twitter-bootstrap - laravel 链接确实有效,但按钮无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20797815/