[英]On redirecting to a View, slide it to the specific part of the page using #id - Laravel 5.3
我有一條重定向到控制器的路由,該控制器告訴視圖顯示。 但是我該如何轉到頁面的特定部分。 讓我解釋:
我正在使用fullpage.js庫來創建頁面斷點。 例如: /home#firstPage
, /home#secondPage
等。 當我重定向到/ home時,我想轉到頁面的特定部分。 我需要的是一種在URL中輸入#3rdPage的方法。
我在哪里以及如何看待它的作用?
Route::get('/home_done', ['as' => 'home_done','uses' => 'HomeController@home']);
public function home()
{
return view('home_done');
}
我想做類似的事情:
return view('home_done#3rdPage');
執行邏輯后,您應該設置一個新功能並路由以將用戶重定向到正確的頁面:
public function home()
{
return view('home_done');
}
public function step_3()
{
// do something and redirect
return redirect('home_done#3rdPage');
}
由於您正在加載文件而非頁面,因此無法使用view
。
當用戶訪問您的頁面時沒有#
認為它等於#firstpage
時,您需要更改JS中的行為。
並在您的html中通過#what_you_need
正確生成url來管理所有頁面。
在您的刀片示例中:
<a href="<?php echo route("home_done") . "#firstpage"; ?>">firstpage</a>
//OR
<a href="<?php echo route("home_done") ?>">firstpage</a> //because this is the same for your JS
<a href="<?php echo route("home_done") . "#secondpage"; ?>">secondpage</a>
或刀片語法
<a href="{{ route("home_done") . "#firstpage"; }}">firstpage</a>
//OR
<a href="{{ route("home_done") }}">firstpage</a> //because this is the same for your JS
<a href="{{ route("home_done") . "#secondpage"; }}">secondpage</a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.