+
+ 首页
+
+
+ 去home
+
+ 去abute
+
+
+```
+
+
+#### 模式的不同
+createWebHashHistory 是hash模式,路由上会有#
+createWebHistory 是history模式,路由上不带#
\ No newline at end of file
--
Gitee
From c5f31efca552d4b82fd4bf0be57879342ffe2780 Mon Sep 17 00:00:00 2001
From: oo <2825532983@qq.com>
Date: Wed, 26 Apr 2023 16:23:43 +0800
Subject: [PATCH 4/6] oo
---
.../20230426-vue\350\267\257\347\224\261.md" | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 "\345\221\250\345\234\206/20230426-vue\350\267\257\347\224\261.md"
diff --git "a/\345\221\250\345\234\206/20230426-vue\350\267\257\347\224\261.md" "b/\345\221\250\345\234\206/20230426-vue\350\267\257\347\224\261.md"
new file mode 100644
index 0000000..f37f5aa
--- /dev/null
+++ "b/\345\221\250\345\234\206/20230426-vue\350\267\257\347\224\261.md"
@@ -0,0 +1,35 @@
+
+
+```js
+import { createApp } from 'vue'
+import App from './App.vue'
+import './assets/main.css'
+import {createRouter,createWebHistroy} from 'vue-router'
+import Hello from './components/HelloWorld.vue'
+import Dome from './components/Dome.vue'
+import Font404 from './components/Font404.vue'
+
+const routes =[
+ {
+ path:'/',
+ component:Hello
+ },
+ {
+ path:'/Dome/:id',
+ component:Dome
+ },
+ {
+ path:'/:abc(.*)',
+ component:Font404
+ }
+]
+const router = createRouter({
+ history:createWebHistroy(),
+ routes
+})
+const app =createApp(app)
+app.use(router);
+app.mount('#app')
+
+
+```
--
Gitee
From 828b278981c7ea4400217c61d82a7fca013f2906 Mon Sep 17 00:00:00 2001
From: oo <2825532983@qq.com>
Date: Fri, 28 Apr 2023 09:31:20 +0800
Subject: [PATCH 5/6] oo
---
...14\345\245\227\350\267\257\347\224\261.md" | 41 +++++++++++++++++++
...76\343\200\201\350\267\257\347\224\261.md" | 31 ++++++++++++++
2 files changed, 72 insertions(+)
create mode 100644 "\345\221\250\345\234\206/20230427-\345\265\214\345\245\227\350\267\257\347\224\261.md"
create mode 100644 "\345\221\250\345\234\206/20230428-\345\221\275\345\220\215\350\247\206\345\233\276\343\200\201\350\267\257\347\224\261.md"
diff --git "a/\345\221\250\345\234\206/20230427-\345\265\214\345\245\227\350\267\257\347\224\261.md" "b/\345\221\250\345\234\206/20230427-\345\265\214\345\245\227\350\267\257\347\224\261.md"
new file mode 100644
index 0000000..ed18e87
--- /dev/null
+++ "b/\345\221\250\345\234\206/20230427-\345\265\214\345\245\227\350\267\257\347\224\261.md"
@@ -0,0 +1,41 @@
+# 嵌套路由
+一些应用程序的 UI 由多层嵌套的组件组成。在这种情况下,URL 的片段通常对应于特定的嵌套组件结构,例如:
+
+/user/johnny/profile /user/johnny/posts
++------------------+ +-----------------+
+| User | | User |
+| +--------------+ | | +-------------+ |
+| | Profile | | +------------> | | Posts | |
+| | | | | | | |
+| +--------------+ | | +-------------+ |
++------------------+ +-----------------+
+
+通过 Vue Router,你可以使用嵌套路由配置来表达这种关系。
+
+# 嵌套的命名路由
+在处理命名路由时,你通常会给子路由命名:
+
+```js
+const routes = [
+ {
+ path: '/user/:id',
+ component: User,
+ // 请注意,只有子路由具有名称
+ children: [{ path: '', name: 'user', component: UserHome }],
+ },
+]
+```
+这将确保导航到 /user/:id 时始终显示嵌套路由。
+
+在一些场景中,你可能希望导航到命名路由而不导航到嵌套路由。例如,你想导航 /user/:id 而不显示嵌套路由。那样的话,你还可以命名父路由,但请注意重新加载页面将始终显示嵌套的子路由,因为它被视为指向路径/users/:id 的导航,而不是命名路由:
+
+```js
+const routes = [
+ {
+ path: '/user/:id',
+ name: 'user-parent',
+ component: User,
+ children: [{ path: '', name: 'user', component: UserHome }],
+ },
+]
+```
\ No newline at end of file
diff --git "a/\345\221\250\345\234\206/20230428-\345\221\275\345\220\215\350\247\206\345\233\276\343\200\201\350\267\257\347\224\261.md" "b/\345\221\250\345\234\206/20230428-\345\221\275\345\220\215\350\247\206\345\233\276\343\200\201\350\267\257\347\224\261.md"
new file mode 100644
index 0000000..2781347
--- /dev/null
+++ "b/\345\221\250\345\234\206/20230428-\345\221\275\345\220\215\350\247\206\345\233\276\343\200\201\350\267\257\347\224\261.md"
@@ -0,0 +1,31 @@
+# 命名路由
+除了 path 之外,你还可以为任何路由提供 name。这有以下优点:
+
+1. 没有硬编码的 URL
+2. params 的自动编码/解码。
+3. 防止你在 url 中出现打字错误。
+4. 绕过路径排序(如显示一个)
+
+```js
+const routes = [
+ {
+ path: '/user/:username',
+ name: 'user',
+ component: User,
+ },
+]
+```
+
+要链接到一个命名的路由,可以向 router-link 组件的 to 属性传递一个对象:
+
+```html
+