亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - vue-router jump problem
僅有的幸福
僅有的幸福 2017-05-19 10:35:53
0
4
624

vue-router
A page jumps to page B. Page B needs to be logged in. If you are not logged in, you need to jump to the login page, and then jump to page B. Now you can jump to the login page, but after logging in How to implement page b to jump to? Because page b is not a fixed page, it may be an exit page, user center page, etc.

僅有的幸福
僅有的幸福

reply all(4)
習(xí)慣沉默
this.$router.go(-1);

Return to the previous route ?

我想大聲告訴你

Wouldn’t it be nice to go back to the previous page?

Ty80

This needs to be processed on the login page, when jumping to the login page

http://登錄頁面URL/login?from=${encodeURLComponent(location.href)}

In this way, on the login page, you can get the from parameter in queryString

After the authentication is completed, it will be OK to jump back according to this from

為情所困

Please refer to the router.beforeEachhook function in the vue-router official documentation, which can be used to implement your functions. The principle is probably:

每次路由跳轉(zhuǎn)都經(jīng)過beforeEach這個鉤子函數(shù),里面的邏輯是若目的地是你需要先校驗登錄狀態(tài)再跳轉(zhuǎn)的頁面,則檢查登錄態(tài),檢查通過則調(diào)用next(),否則跳轉(zhuǎn)到登錄頁,并且?guī)系膓uery是目的頁面的fullPath,用于登錄后跳轉(zhuǎn)到目的頁面用。

If you have any questions, please chat privately~

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template