图纸翻译的钱,到底该按什么付?按年按⻚按字数买断
2026/7/19 3:07:08
@[toc]
很多项目后期路由文件看起来像这样:
说白了就是一句话:
路由和页面结构是“边写边凑”的。
一句话定义 Layout:
只管结构,不管业务。
Layout 里应该有什么?
<router-view />不应该有什么?
Layout ├─ Header ├─ Sidebar └─ MainContent (router-view)这个结构的好处是:
{path:'/',component:MainLayout,children:[{path:'dashboard',component:Dashboard}]}这样做的本质是:
Layout 是路由的一部分,而不是页面自己引的组件
真实项目里几乎一定有:
解决方式非常简单:
{path:'/login',component:BlankLayout},{path:'/',component:AdminLayout,children:[...]}你会发现:
不要自己维护一份菜单数据。
constmenus=routes.map(route=>({title:route.meta.title,path:route.path}))这样做的好处是:
router/ ├─ index.ts ├─ modules/ │ ├─ user.ts │ ├─ order.ts │ └─ admin.ts每个模块只关心自己:
路由是页面结构的说明书,不是业务代码的垃圾桶。