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

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

内容简介:如何使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');

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

查看所有标签

猜你喜欢:

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

Designing Data-Intensive Applications

Designing Data-Intensive Applications

Martin Kleppmann / O'Reilly Media / 2017-4-2 / USD 44.99

Data is at the center of many challenges in system design today. Difficult issues need to be figured out, such as scalability, consistency, reliability, efficiency, and maintainability. In addition, w......一起来看看 《Designing Data-Intensive Applications》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具