vendredi 18 juin 2021

Routing with if condition in vue.js

This is my code within in router.js file

 {
      name: "Admin",
      path: "/admin/",
      component: () => import("@/views/admin/Index"),
      children: [
      
        // Dashboard
        {
          name: "Dashboard",
          path:   "dash",
          component: () => import("@/views/admin/Dash"),
        },
        {
          name: "Campaign Management",
          path: "campaign",
          component: () =>
          import("@/views/CampaignManagementNew/CampaignManagment"),
        },
   ]
}

I set a variable 'status' in the localStorage.

I want to route only, if 'status' is true (localStorage item). Otherwise, I not need to routing to child components.

How I use if conditions to routing?

Aucun commentaire:

Enregistrer un commentaire