vue clears dynamic routing
Dynamic routes are often added in projects, and how to delete routes that have been added is often ignored. Here is a record of this:
Check the vue-router routing document. It can be seen that in Vue2, the matcher is used to clear the value.
let createRouter = () => new Router({ mode: 'history', //hash history backend supports openable, nginx is required, and the 404 interface will not be returned to the second mode. routes: constantRouterMap, //Routing path scrollBehavior: () => ({ y: 0 }) // Position the position of the routing scrollbar during switching}); const router = createRouter() export function resetRouter () { // Method to clear the route const newRouter = createRouter() = } export default router;
There is no matcher attribute in Vue3, so you need to clear the route by loop traversal.
const router = createRouter({ routes, history: createWebHashHistory() }) (()); //Reset the routeexport function resetRouter(){ let routers = () (routers); ((it:any)=>{ if(!()){ () } }) (routers); }
** Note: whiteList is a whitelist.
This is the end of this article about vue clearing dynamic routing. For more related vue clearing dynamic routing content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!