From 05fbe8187ed7c18320c1cab16b5d3fe6c1b93609 Mon Sep 17 00:00:00 2001 From: yumaojun03 <719118794@qq.com> Date: Sun, 5 Jan 2025 18:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=90=8E=E5=8F=B0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vblog/web/README.md | 27 ++++++++ vblog/web/src/router/index.js | 13 ++++ vblog/web/src/views/backend/BackendLayout.vue | 67 +++++++++++++++++++ vblog/web/src/views/backend/blog/ListPage.vue | 11 +++ 4 files changed, 118 insertions(+) create mode 100644 vblog/web/src/views/backend/BackendLayout.vue create mode 100644 vblog/web/src/views/backend/blog/ListPage.vue 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 @@ + + + + +