vue3 路由切换出现问题

最近正在用vue3开发项目,然后在APP.vue中通过router.beforeEach来判断客户是否登录来判断是否跳转。使用 router.push("/MyNotes")进行路由跳转。我从A页面跳转到B页面,已经跳转到B页面了,但是发现A页面的onMounted里方法居然被调用了。这是为什么?

app.vue中

onMounted(() => {
console.log("router.currentRoute",router,router.currentRoute.value.fullPath,)
})
const unwatch = router.beforeEach((to, from, next) => {
let userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
console.log("getIsShowSearch", userInfo, to.path,)
if (to.path == '/Login') {
// 如果路径是 /login 则正常执行
next()
} else {
// 如果不是 /login,判断是否有 token
if (!!!userInfo) {
// 如果没有,则跳至登录页面
next({ path: '/Login' })
} else {
// 否则继续执行
next()
}
//next()
}
state.showMenu = !noMenu.includes(to.path)
console.log("noMenu.includes(to.path)", to.path, state.showMenu, state.currentPath)
state.currentPath = to.path
// document.title = pathMap[to.name]
})