diff --git a/vblog/web/README.md b/vblog/web/README.md index 9d7a7fe..6e69ffe 100644 --- a/vblog/web/README.md +++ b/vblog/web/README.md @@ -295,3 +295,30 @@ client.interceptors.response.use( }, ) ``` + +## 路由嵌套与布局 + +https://router.vuejs.org/zh/guide/essentials/nested-routes.html + +```js +const routes = [ + { + path: '/user/:id', + component: User, + children: [ + { + // 当 /user/:id/profile 匹配成功 + // UserProfile 将被渲染到 User 的 内部 + path: 'profile', + component: UserProfile, + }, + { + // 当 /user/:id/posts 匹配成功 + // UserPosts 将被渲染到 User 的 内部 + path: 'posts', + component: UserPosts, + }, + ], + }, +] +``` diff --git a/vblog/web/src/router/index.js b/vblog/web/src/router/index.js index 3119579..a2e6108 100644 --- a/vblog/web/src/router/index.js +++ b/vblog/web/src/router/index.js @@ -21,6 +21,19 @@ const router = createRouter({ name: 'login', component: () => import('../views/common/LoginPage.vue'), }, + // 后台管理 + { + path: '/backend', + name: 'backend', + component: () => import('../views/backend/BackendLayout.vue'), + children: [ + { + path: 'blog', + name: 'backend_blog_list', + component: () => import('../views/backend/blog/ListPage.vue'), + }, + ], + }, ], }) diff --git a/vblog/web/src/views/backend/BackendLayout.vue b/vblog/web/src/views/backend/BackendLayout.vue new file mode 100644 index 0000000..473c2c7 --- /dev/null +++ b/vblog/web/src/views/backend/BackendLayout.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/vblog/web/src/views/backend/blog/ListPage.vue b/vblog/web/src/views/backend/blog/ListPage.vue new file mode 100644 index 0000000..43789dd --- /dev/null +++ b/vblog/web/src/views/backend/blog/ListPage.vue @@ -0,0 +1,11 @@ + + + + +