W
W
WebDev2019-01-28 13:37:00
Vue.js
WebDev, 2019-01-28 13:37:00

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>

Now this method will not work, because I can’t take out the product page into the components. Titles and meta information will not be pulled up, and you cannot import a file from /pages either.
I am offered some incomprehensible game in the form
router: {
    extendRoutes (routes) {
      // Update 
      routes.find((r) => r.path.includes('pages/product/_id.vue')).path = '/produtos/:id'
    }
  }

I did not understand how to use it, I tried everything, it does not work.
Explain to me, please, why did you make another routing? What are the benefits of the new one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Klein Maximus, 2019-02-13
@kleinmaximus

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 question

Ask a Question

731 491 924 answers to any question