//使用钩子函数对路由进行权限跳转
router.beforeEach((to, from, next) => {
document.title = `${to.meta.title}`;
const userName = localStorage.getItem('userName');
if (!userName && to.path !== '/login') {
next('/login');
} else if (to.meta.permission) {
userName === 'admin' ? next() : next('/404');
} else {
next();
}
});
【フロントエンド】router.beforeEachナビゲーションガードのパーミッションジャンプ
おすすめ
転載: blog.csdn.net/weixin_43853746/article/details/121773638
ランキング