链接到Laravel页面上的特定锚点 [英] link to specific anchor on a page with Laravel
本文介绍了链接到Laravel页面上的特定锚点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Laravel链接到视图中的特定ID?
How does one go about linking to a specific id in a view with Laravel?
我的控制器:
public function services() {
return View::make('services.custom_paint', array('pageTitle' => 'Custom Paint'))->with('default_title', $this->default_title);
}
我的路线:
Route::get('/custom_paint', 'PagesController@services');
我试图将#id
添加到路由,控制器甚至视图的URL::to
中.似乎没有任何作用.
I have tried to add #id
to the route, to the controller, and even to the view's URL::to
. Nothing seems to work.
我以为只要在URI上添加id就可以解决问题,但显然我遗漏了一些东西.
I assumed that simply adding the id on to the URI would do the trick, but clearly I am missing something.
推荐答案
// Controller
Route::get('/custom_paint', array('as' => 'custom_paint', 'uses' => 'PagesController@services'));
// View
<a href="{{ URL::route('custom_paint') }}#id">LINK</a>
尝试此代码;)希望它能起作用.
Try this code ;) hope it works..
这篇关于链接到Laravel页面上的特定锚点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文