The site has pages with content and login and registration pages. So, for the content, a certain static part with a cap, footer and menu is used, but for entry and registration, another static part is needed. How to use vue-router to do this?

Router code

Point of entry

Can I prescribe something in the component itself, so that it uses another template? If not, how to do it at all?

  • 2
    Please insert the code itself into the question, the picture does not fit as search engines do not index it - Dmitry Polyanin
  • In the App, make 2 markup options and use the v-if v-else to put the desired one. Check the current router. if it is '/ auth' or '/ reg', give the first one if any other then the second. Or another option is to make the App neutral, create 2 components with the necessary layout. and invest in them all the rest as children. - Yaroslav Zaika

1 answer 1

In your App.js, you can use a component wrapper or the following construction:

<component :is="routeListener"></component> Импортируете ваши LayoutContent и LayoutAuth components: { LayoutContent, LayoutAuth }, computed: { routeListener () { // тут проверку по пути делаете if (this.$router.path === '/reg' || this.$router.path === '/auth') return 'layout-auth' else return 'layout-content' } }