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/