Answer the question
In order to leave comments, you need to log in
Why is routing so poorly implemented in nuxt?
What for was to do the routing tied on files and directories? Normal and convenient routing is in vue, why was it so perverted? It's inflexible, inconvenient, and generally reeks of junk.
In Zend-Framework, I remember, there was something similar: Type module-name/controller-name/method-name. And then I switched to Laravel and like a breath of fresh air. And here it’s the other way around: there was a convenient routing in vue, they took it and ruined it.
It also adds work when moving from vue to nuxt. I had to rewrite everything. Could immediately earn, but now you have to redo it.
In addition, for example, I have a few things that I can't do.
For example, I have the same component (page) should open at different addresses. The main page "/" should, under certain circumstances, open the product page "/:productId". Previously, this was solved simply by importing the desired component:
//index.vue
<ProductComponent v-if="someConditions"></ProductComponent>
<template v-else>
..index page content
</template>
router: {
extendRoutes (routes) {
// Update
routes.find((r) => r.path.includes('pages/product/_id.vue')).path = '/produtos/:id'
}
}
Answer the question
In order to leave comments, you need to log in
Essentially, Nuxt is just a collection of templates.
You can add your router there.
Or try https://github.com/nuxt-community/router-module
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question