router.beforeEach((to, from, next) => { if (to.matched.some(record => record.name == 'Admin')) { console.log('我是Admin'); next() } else { console.log('我是发布页'); next() // 确保一定要调用 next() } }) }) 扩展阅读 Vue3 动态路由 一篇搞定Vue Router 路由守卫(导航守卫)