我想在我的html文件中使用URL
方法指向URL::to()
。但我也想要,当有人点击链接时,我可以用它发送一些数据。那么,我怎样才能将参数传递给la {URL::to()
方法。对于前 - 。
我想这样做 -
URL::to('search')->with('x','12');
根据Laravel文档,我将把这个方法放在'{{}}
'的html文件中。我搜索了网络以及laravel文档,但找不到任何针对此特定问题的内容。而且,我无法找到任何其他方法。
更新:已解决。 URL :: route()完成了工作。
答案 0 :(得分:1)
您可以使用:
link_to('foo/bar', $title, $attributes = array(), $secure = null);
例如:
{{ link_to('foo/bar/' . $param1, 'Goto Foo') }}
或者这样:
{{ link_to("foo/bar/$param1", 'Goto Foo') }}
Check the documentation。此外,如果您使用route
,则可以轻松地在单独的数组{{ route('routename', array('username' => $user->username))
中传递参数。