Why did you re-enter beforeEach after vue-router addRoutes?

  1. in the router object hook beforeEach, I use the addRoutes method to dynamically add a route to the router and find infinite calls to beforeEach,. I want to know why? As shown in the figure

clipboard.png
reference link: https://jsfiddle.net/L7hscd8h.

Mar.04,2021

do not use / * , * number for a specific name


  1. you can put 404 routes last according to the official lazy load;

    const router = new VueRouter({
        mode: 'history',
        routes: [
            { path: '*', component: NotFoundComponent }
        ]
    })
  2. reference article: addRoutes; it is also implemented to load 404 at last
Menu