保存进度!
This commit is contained in:
		
							
								
								
									
										7
									
								
								入门/cli/hello-router/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								入门/cli/hello-router/package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -10126,14 +10126,11 @@
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/vue-router": {
 | 
					    "node_modules/vue-router": {
 | 
				
			||||||
      "version": "4.1.6",
 | 
					      "version": "4.1.6",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.1.6.tgz",
 | 
					      "resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.1.6.tgz",
 | 
				
			||||||
      "integrity": "sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==",
 | 
					      "integrity": "sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==",
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "@vue/devtools-api": "^6.4.5"
 | 
					        "@vue/devtools-api": "^6.4.5"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "funding": {
 | 
					 | 
				
			||||||
        "url": "https://github.com/sponsors/posva"
 | 
					 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      "peerDependencies": {
 | 
					      "peerDependencies": {
 | 
				
			||||||
        "vue": "^3.2.0"
 | 
					        "vue": "^3.2.0"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -18741,7 +18738,7 @@
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    "vue-router": {
 | 
					    "vue-router": {
 | 
				
			||||||
      "version": "4.1.6",
 | 
					      "version": "4.1.6",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.1.6.tgz",
 | 
					      "resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.1.6.tgz",
 | 
				
			||||||
      "integrity": "sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==",
 | 
					      "integrity": "sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==",
 | 
				
			||||||
      "requires": {
 | 
					      "requires": {
 | 
				
			||||||
        "@vue/devtools-api": "^6.4.5"
 | 
					        "@vue/devtools-api": "^6.4.5"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 * @Author: Kane
 | 
					 * @Author: Kane
 | 
				
			||||||
 * @Date: 2022-11-24 01:13:55
 | 
					 * @Date: 2022-11-24 01:13:55
 | 
				
			||||||
 * @LastEditors: Kane
 | 
					 * @LastEditors: Kane
 | 
				
			||||||
 * @LastEditTime: 2022-11-24 01:47:59
 | 
					 * @LastEditTime: 2022-11-24 09:51:12
 | 
				
			||||||
 * @FilePath: \hello-router\src\App.vue
 | 
					 * @FilePath: \hello-router\src\App.vue
 | 
				
			||||||
 * @Description: 
 | 
					 * @Description: 
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
@@ -12,7 +12,9 @@
 | 
				
			|||||||
  <!-- <img alt="Vue logo" src="./assets/logo.png" /> -->
 | 
					  <!-- <img alt="Vue logo" src="./assets/logo.png" /> -->
 | 
				
			||||||
  <h1>测试vue-router</h1>
 | 
					  <h1>测试vue-router</h1>
 | 
				
			||||||
  <router-link to="/demo-1">页面一</router-link><br />
 | 
					  <router-link to="/demo-1">页面一</router-link><br />
 | 
				
			||||||
  <router-link to="/demo-2">页面二</router-link>
 | 
					  <router-link to="/demo-2">页面二</router-link><br />
 | 
				
			||||||
 | 
					  <router-link to="/user/Kane">Kane</router-link><br />
 | 
				
			||||||
 | 
					  <router-link to="/user/Aga">Aga</router-link>
 | 
				
			||||||
  <hr />
 | 
					  <hr />
 | 
				
			||||||
  <router-view></router-view>
 | 
					  <router-view></router-view>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										33
									
								
								入门/cli/hello-router/src/components/功能页面/路由守卫.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								入门/cli/hello-router/src/components/功能页面/路由守卫.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					<!--
 | 
				
			||||||
 | 
					 * @Author: Kane
 | 
				
			||||||
 | 
					 * @Date: 2022-11-24 09:42:35
 | 
				
			||||||
 | 
					 * @LastEditors: Kane
 | 
				
			||||||
 | 
					 * @LastEditTime: 2022-11-24 09:58:11
 | 
				
			||||||
 | 
					 * @FilePath: \hello-router\src\components\功能页面\路由守卫.vue
 | 
				
			||||||
 | 
					 * @Description: 
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <h1>路由守卫</h1>
 | 
				
			||||||
 | 
					  <h1>{{ user.name }}</h1>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
					export default {
 | 
				
			||||||
 | 
					  name: "route-guard",
 | 
				
			||||||
 | 
					  data() {
 | 
				
			||||||
 | 
					    return {
 | 
				
			||||||
 | 
					      user: {
 | 
				
			||||||
 | 
					        name: "",
 | 
				
			||||||
 | 
					        age: 20,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  beforeRouteUpdate(to) {
 | 
				
			||||||
 | 
					    alert(to.params.username);
 | 
				
			||||||
 | 
					    this.user.name = to.params.username;
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					<style scoped>
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 * @Author: Kane
 | 
					 * @Author: Kane
 | 
				
			||||||
 * @Date: 2022-11-24 01:13:55
 | 
					 * @Date: 2022-11-24 01:13:55
 | 
				
			||||||
 * @LastEditors: Kane
 | 
					 * @LastEditors: Kane
 | 
				
			||||||
 * @LastEditTime: 2022-11-24 01:34:13
 | 
					 * @LastEditTime: 2022-11-24 09:59:55
 | 
				
			||||||
 * @FilePath: \hello-router\src\main.js
 | 
					 * @FilePath: \hello-router\src\main.js
 | 
				
			||||||
 * @Description: 
 | 
					 * @Description: 
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
@@ -10,24 +10,23 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { createApp } from "vue";
 | 
					import { createApp } from "vue";
 | 
				
			||||||
import { createRouter, createWebHashHistory } from "vue-router";
 | 
					import { createRouter, createWebHashHistory } from 'vue-router';
 | 
				
			||||||
import App from "./App.vue";
 | 
					import App from "./App.vue";
 | 
				
			||||||
import Demo1 from "./components/功能页面/demo-1.vue";
 | 
					import demo1 from "./components/功能页面/demo-1.vue";
 | 
				
			||||||
import Demo2 from "./components/功能页面/demo-2.vue";
 | 
					import demo2 from "./components/功能页面/demo-2.vue";
 | 
				
			||||||
 | 
					import rg from "./components/功能页面/路由守卫.vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const app = createApp(App);
 | 
					const app = createApp(App);
 | 
				
			||||||
 | 
					 | 
				
			||||||
//定义路由
 | 
					 | 
				
			||||||
const routes = [
 | 
					const routes = [
 | 
				
			||||||
    { path: "/demo-1", component: Demo1 },
 | 
					    { path: "/demo-1", component: demo1 },
 | 
				
			||||||
    { path: "/demo-2", component: Demo2 },
 | 
					    { path: "/demo-2", component: demo2 },
 | 
				
			||||||
 | 
					    { path: "/user/:username", component: rg }
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//创建路由对象
 | 
					 | 
				
			||||||
const router = createRouter({
 | 
					const router = createRouter({
 | 
				
			||||||
    history: createWebHashHistory(),
 | 
					    history: createWebHashHistory(),
 | 
				
			||||||
    routes: routes
 | 
					    routes: routes
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.use(router);
 | 
					app.use(router);
 | 
				
			||||||
app.mount("#app");
 | 
					app.mount("#app");
 | 
				
			||||||
		Reference in New Issue
	
	Block a user