Routing in the vue project system has no permission to jump 404 to jump 401

When the customer enters a new page without permission, open a new tab and prompt the customer "sorry! You do not have permission to go to this page". The route outside the system still jumps to 404.

Solutions:

Here, the backend needs to provide an interface to pass the current route. If it is the route interface in the system, it returns true, and if not, it returns false.

When the route jumps to 404, the interface is judged. If it returns true, then jump to 401 page, if false, continue to jump to 404.

The core code is as follows:

 

Note here that the parameters do not need to be passed to the backend, which route does to.redirectedFrom come in from. 

if (to.path === '/404' && to.redirectedFrom) {
    let routerParam = to.redirectedFrom.split(

Guess you like

Origin blog.csdn.net/weixin_39089928/article/details/131391666