Laravel-如何使用哈希重定向(#) [英] Laravel - How to redirect with hash (#)

查看:65
本文介绍了Laravel-如何使用哈希重定向(#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有链接:

example.com/register#register

如果验证失败,laravel将重定向到:

If validation fails laravel redirects to :

example.com/register

具有验证错误位,不包含哈希网址部分.如何使用#重定向到完整网址?

with validation errors bit without hash url part. How I can redirect to full url with # ?

我知道我可以使用:

Redirect::to(route('register') . '#credits')

但是我想要完整的解决方案,所以我和我的

But I want complete solution so and my :

return back();

将使用#重定向.

也许我需要重写一些代码?

Maybe I need to override some code ?

推荐答案

您可以先使用路由名称创建URL.

You could create the URL first, using the route name.

$url = URL::route('route_name', ['#hash_tag']);

Redirect::to($url);

或者...

return Redirect::to(URL::previous() . "#hash_tag");

这篇关于Laravel-如何使用哈希重定向(#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆