📜  使用元标记 firebase 路由 vue - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:57.053000             🧑  作者: Mango

代码示例1
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({
  ...