📅  最后修改于: 2022-03-11 15:03:57.053000             🧑  作者: Mango
const router = new VueRouter({
...
});
router.beforeEach((to, from, next) => {
const currentUser = firebase.auth().currentUser;
const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
if (requiresAuth && !currentUser) next('login');
else if (!requiresAuth && currentUser) next('dashboard');
else next();
});
new Vue({
...