将锚添加到Laravel重定向回 [英] Add an anchor to Laravel redirect back
本文介绍了将锚添加到Laravel重定向回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Laravel控制器中,我具有以下重定向:
In a Laravel controller I have this redirect:
return redirect()->back();
这使我回到上一页(例如 http://domain/page ).但是,我想使页面跳转到特定锚点(例如#section).因此,最终应打开此页面: http://domain/page#section .我怎样才能做到这一点?我尝试将锚添加到重定向,但这不起作用.
Which returns me to my previous page (say http://domain/page). However, I want to make the page jump to a particular anchor (say #section). So ultimately this page should be opened: http://domain/page#section. How can I make this happen? I tried appending the anchor to the redirect but that doesn't work.
推荐答案
return Redirect::to(URL::previous() . "#whatever");
并记住将其导入顶部:
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\URL;
我希望这对您有用!
这篇关于将锚添加到Laravel重定向回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文