The navigation menu of ElementUI is not logged in to change the route

first of all, the navigation menu of ElementUI can be used normally.
now I"m going to make a login judgment. If you don"t log in, click "Security Center" and "Finance Center" in the navigation, and the interface will jump to the login screen

.

now the problem is that you can"t jump to the login interface
code is as follows. I hope you can solve the problem, or is there any other way

handleSelect(key, keyPath) {
    //console.log(key,keyPath)keykeyPath
    const token = Cookies.get("loginToken");//token
    if(key === "safety" || key === "financial"){//safetyfinancial
    
        if (!token || token == "") {

            this.$router.push({path: "/login"});

            console.log(this.$route.path)// "/login" 
        }
    }
}
Jul.19,2022

judging
pseudo code in route interception

router.beforeEach((to, from, next) => {
    if() {
            next({
                path: '/logIn'
            });    
    } else {
        next()
    }
})
Menu