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');

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

查看所有标签

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

Data Structures and Algorithms in Python

Data Structures and Algorithms in Python

Michael T. Goodrich、Roberto Tamassia、Michael H. Goldwasser / John Wiley & Sons / 2013-7-5 / GBP 121.23

Based on the authors' market leading data structures books in Java and C++, this book offers a comprehensive, definitive introduction to data structures in Python by authoritative authors. Data Struct......一起来看看 《Data Structures and Algorithms in Python》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具