分类 学员周报 下的文章

Vue 动态路由逆向与 Hook 实战教学

一、理论基础1.1 什么是动态路由在传统的 Vue 应用中,所有路由通常在 router/index.js 中写死,这种写法的特点是:打开 JS 文件就能看到所有路由,路由表是静态的、完整的。// 典型的静态路由 —— 所有路由一目了然 const routes = [ { path: '/login', component: Login }, { path: '/dashboard', component: Dashboard }, { path: '/user/list', component: UserList }, { path: '/user/detail/:id', component: UserDetail }, { path: '/admin/settings', component: AdminSettings }, // ... 可能几十条,但全部写在这里 ];但还有一种更复杂的情况 —— 动态路由。开发者在 router/index.js 中

目录

目录