php – Laravel:如何使用尾部斜杠创建路由路由返回URL?

栏目: PHP · 发布时间: 7年前

内容简介:如何使Laravel 5.3创建带有斜杠的路径URL?路线定义为然后我在视图中使用路径助手函数创建url:

如何使 Laravel 5.3创建带有斜杠的路径URL?

路线定义为

Route::get('/home/', ['as' => 'home', 'uses' => 'HomeController@index']);

然后我在视图中使用路径助手函数创建url:

{{ route('home') }}

这将创建http:// localhost:8000 / home而不是http:// localhost:8000 / home /.

这个问题与 Laravel – append a trailing slash in routes 非常相似,但这个问题也没有答案,而且在我看来,我的描述更短.

编辑:

文档中两种可能的命名方法没有区别:

Route::get('/home/', ['as' => 'home', 'uses' => 'HomeController@index']);
Route::get('/home/', 'HomeController@index')->name('home');

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The CS Detective: An Algorithmic Tale of Crime, Conspiracy, and

The CS Detective: An Algorithmic Tale of Crime, Conspiracy, and

Jeremy Kubica / No Starch Press / 2016-8-15 / USD 13.74

Meet Frank Runtime. Disgraced ex-detective. Hard-boiled private eye. Search expert.When a robbery hits police headquarters, it's up to Frank Runtime and his extensive search skills to catch the culpri......一起来看看 《The CS Detective: An Algorithmic Tale of Crime, Conspiracy, and 》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具