You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is very common to add routes asynchronously and dynamically, such as dynamically adding accessible routes to the data returned through the interface. When accessing the page initially, because the route data is added to the route asynchronously, there is no route of the current path, so an error such as "no match found for location with path /xxx" will be reported.
During router 3.x, you can get asynchronous data and inject routing data, and then display the root router view to solve this problem. The specific methods are as follows.
However, using router next, the above methods are no longer effective. Therefore, we hope to add a start method to the router instance. After all routing data is added to the route, start vue-router through the start method, so as to solve this problem perfectly.
What does the proposed API look like?
constrouter=createRouter({});router.addRoute({path: '/aaa',name: 'aaa',component: ()=>import('@/views/Aaa.vue'),});// This method really starts the router// Global can only be called once, and multiple calls are invalidrouter.start();