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
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
Previous: Compilation error during the use of iview
Next: There is no images folder in the dist directory after webpack is packaged?