G
G
guerrrka2018-10-05 23:05:49
Vue.js
guerrrka, 2018-10-05 23:05:49

How to implement this through vue routes?

There is a template (I don’t know how to name it correctly) and it contains a point for components (router-view). How can I make the /register and /login routes open in this template (I already did it), and for example /app without this template?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Klein Maximus, 2018-10-06
@guerrrka

Option 2:
1) Connect the required template component in the page components. That is, in your case, in those components that are shown on the /register and /login routes, add a template component.

<template>
  <layout-custom>
    <!-- тут код компонентов -->
  </layout-custom>
</template>

But in this case, you need to specify in the template not router-view, but slot.
2) Do it through the router settings:
const router = new Router({
  routes: [
    {
      // Без шаблона
      path: '/app',
      component: AppPage,
    },
    {
      // С шаблоном
      path: '/',
      component: LayoutCustom,
      children: [
        {
          path: '/register',
          component: RegisterPage,
        },
        {
          path: '/login',
          component: LoginPage,
        }
      ], 
    },
  ],
});

M
mShpakov, 2018-10-05
@mShpakov

This template is the root entry point It is
used essentially as a layout, and the pages themselves on a certain template are its child pages
For an example of implementation, see nuxt js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question