What should I do when there are too many routes in Vue-router (am I writing this correctly?)

clipboard.png

clipboard.png

as there are more and more routes, more and more components are introduced into router.js, and each particular page corresponds to a different component.
is this a reasonable way to write? It feels weird


to improve maintainability. You can split it into multiple files according to the page, which is nothing more than importing and exporting a routing object.


if the page structure is exactly or almost the same, try routing parameters, or dynamic routing.


Let me answer in more detail

there is a router.js, outside and each module of pages has its own router.js

the outer one is only responsible for loading the inner one. Add

via router.addRoutes .

what is in the module is where the routing is configured

it is also important to use import to dynamically load routes

Menu