A
A
Andrew2019-01-09 07:03:30
Vue.js
Andrew, 2019-01-09 07:03:30

Concise routing in vue?

How can vk-like routing be implemented?
That is, site.ru/id*** = the Profile component, site.ru/group*** = the Group component, and the main page changes depending on whether the user is authorized. That is, if authorized, then site.ru = Dashboard, and if not, then Landing.
At the moment, everything is built on a very deep nesting, which is inconvenient and ugly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artray, 2019-01-09
@AndrewRusinas

How can vk-like routing be implemented?
That is, site.ru/id*** = Profile component, site.ru/group*** = Group component

new Router({
  // ...
  routes: [
    {
      path: '/(id):id',
      name: 'Profile',
      component: Profile,
    },
    {
      path: '/(group):groupId',
      name: 'Group',
      component: Group,
    },
  ],
});

// Home.vue
<Dashboard v-if="isAuth" />
<Landing v-else />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question