通過url傳參的方式實現頁面回跳

2021-10-10 02:21:42 字數 1134 閱讀 2806

實現步驟:

1.在響應***跳轉時新增引數

window.location.href = '#/login?returuurl=' + window.location.hash.substr(1)

2.在登入成功時判斷是否攜帶引數,是則返回傳參頁

應用場景:使用者瀏覽頁面需要進行登入時,為避免找不回瀏覽記錄,在登入後返回登入前瀏覽的頁面。

// 新增響應***

axios.interceptors.response.

use(

function

(response)

return response;},

function

(error)

);

跳轉成功後url效果

console.

log(window.location.hash)

;// 雜湊值: #/login?returuurl=%2farticledetail%2f10

console.

log(window.location.hash.

split

("=")[

1]);

// 擷取需要的雜湊值: %2farticledetail%2f10

console.

log(

decodeuricomponent

(window.location.hash.

split

("=")[

1]))

;// 解碼後: /articledetail/10

let url =

decodeuricomponent

(window.location.hash.

split

("=")[

1]);

if(url && url !=

"undefined"))

;}else` }

);}}

通過URL傳參(引數也是URL)

encodeuricomponent 函式可把字串作為 uri 元件進行編碼。if pagetype val treepage 想通過url傳遞引數childlinkurl,後台接收這個引數。此引數是另一url 起初在傳參的時候 是按照 url 正常的拼接引數 來拼接的 在w3c上查到就解決了此問題...

頁面傳參的幾種方式

頁面之間傳值的幾種方法1.get方式 傳送頁 response.redirect webforma2.aspx?name textbox1.text 接收頁 this.textbox1.text request name name name 2.使用記憶體變數 傳送頁 接收頁 3.post方式 傳送...

Springboot頁面傳參的方式總結

requestbody 不能通過表單和url 傳參 value test apioperation value 開始流程 notes 開始流程 public r test requestbody testdemo startprocessinstancereq postman測試注意傳參使用 bod...