[英]How to route in laravel with anchor tag?
Below is my code in web.php 下面是我在web.php中的代码
$api->get('admin/views/query/new_query', 'AdminViewsController@answer_to_query');
In my controller: 在我的控制器中:
public function answer_to_query() {
return view('admin.query.new_query');
}
In my view: 在我看来:
<div class="btn-group">
<a href="#/query_list/answer_to_query" class="btn btn-xs green" type="button" data-toggle="dropdown" aria-expanded="false" ui-sref="querydtlsController"> View<i class="fa fa-angle"></i>
</a>
</div>
I dont know how to call my method answer_to_query
from above page to display my new_query
page. 我不知道如何从上面的页面调用我的方法
answer_to_query
来显示我的new_query
页面。
如果由于某种原因不想为路由命名,可以使用url()
帮助程序:
<a href="{{ url('admin/views/query/new_query') }}"
Try this one 试试这个吧
Web.php Web.php
$api->get('admin/views/query/new_query', 'AdminViewsController@answer_to_query')->name('answer_to_query_view');
View.blade.php View.blade.php
<a href="{{route('answer_to_query_view')}}" class="btn btn-xs green" type="button" data-toggle="dropdown" aria-expanded="false" ui-sref="querydtlsController"> View<i class="fa fa-angle"></i>
I prefer using named routes since it is much easier to organize instead of always making the link manually 我更喜欢使用命名路由,因为它更容易组织而不是总是手动创建链接
Source: https://laravel.com/docs/5.5/routing#named-routes 资料来源: https : //laravel.com/docs/5.5/routing#named-routes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.