redirect - 如果我不使用 Blade 或任何模板,如何使用 href 标签重定向到 laravel 5 中的路由?

标签 redirect routes laravel-5 href

Route::get('/page','UserController@view page'); 

是我的路线。

我有一个带有 href 标签的列表,我想重定向到这条路线。
<ul>
    <li><a href="">how it works</a></li>
</ul>

我没有使用 Blade 或任何其他模板。

最佳答案

除了@chanafdo 回答,您还可以使用路由名称

使用 laravel Blade 时
<a href="{{route('login')}}">login here</a> 在路由名称中带有参数

当转到像 URI 这样的 url 时:profile/{id} <a href="{{route('profile', ['id' => 1])}}">login here</a>
无 Blade
<a href="<?php echo route('login')?>">login here</a>
在路由名称中带有参数

当转到像 URI 这样的 url 时:profile/{id} <a href="<?php echo route('profile', ['id' => 1])?>">login here</a>
从 laravel 5.2 开始,您可以 use @php @endphp创建为 <?php ?>在 laravel Blade 中。
使用 Blade 您的个人意见,但我建议使用它。学习它。
它有许多精彩的功能,如template inheritance , Components & Slots , subviews ETC...

关于redirect - 如果我不使用 Blade 或任何模板,如何使用 href 标签重定向到 laravel 5 中的路由?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34081841/

相关文章:

python - 如何使用 curl 或请求捕获重定向

redirect - 如何删除发布请求nginx的尾部斜线

php - Laravel 5 PHPUnit - 从路由返回无效的 JSON

laravel - Laravel 5.3 用户模型中的 CanResetPassword

php - 如何使用输入重定向回表单 - Laravel 5

javascript - Angular View 自动重定向到默认(否则) View

ruby-on-rails - 2 个域使用相同的主机,但路由不同

asp.net - 路由到另一个页面上的 anchor

php - 使用 laravel crinsane cart 搜索购物车中的商品

php - 即使事件被触发,Laravel Listener 也没有被触发