From c9280a414af83d54be991ff4e65397a9cd195ded Mon Sep 17 00:00:00 2001
From: Ruin <1830275783@qq.com>
Date: Wed, 9 Mar 2022 14:02:12 +0800
Subject: [PATCH] commit
---
src/app/app-routing.module.ts | 7 ++++++-
src/app/app.module.ts | 2 +-
src/app/model/public.module.ts | 5 +++--
src/app/pages/home/home.component.html | 10 +++++++---
src/app/pages/home/home.component.ts | 10 ++++++++--
src/app/pages/home/home.module.ts | 3 ++-
src/app/pages/user/user.component.html | 6 ++++--
src/app/pages/user/user.component.ts | 19 ++++++++++++++++---
src/app/pages/user/user.module.ts | 2 +-
src/styles.scss | 3 +++
10 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index e76731c..bd2a25b 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -4,7 +4,7 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 16:21:23
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-09 10:52:56
+ * @LastEditTime: 2022-03-09 14:00:45
*/
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
@@ -20,6 +20,11 @@ const routes: Routes = [
path: "user",
component: UserComponent,
},
+ // 匹配不到路由时加载的组件或者跳转的路由
+ {
+ path: "**",
+ redirectTo: "",
+ },
];
@NgModule({
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 0e2494f..e39639a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -4,7 +4,7 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 16:21:23
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-09 11:39:39
+ * @LastEditTime: 2022-03-09 13:41:44
*/
// 引入核心模块
import { NgModule } from "@angular/core";
diff --git a/src/app/model/public.module.ts b/src/app/model/public.module.ts
index 65b666d..550ebdc 100644
--- a/src/app/model/public.module.ts
+++ b/src/app/model/public.module.ts
@@ -4,7 +4,7 @@
* @Author: Ruin 🍭
* @Date: 2022-03-09 11:13:29
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-09 11:40:26
+ * @LastEditTime: 2022-03-09 13:39:27
*/
import { NgModule } from "@angular/core";
import { AppRoutingModule } from "../app-routing.module";
@@ -12,9 +12,10 @@ import { ComponentsModule } from "src/app/components/components.module";
import { CommonModule } from "@angular/common";
// 引入双向数据绑定
import { FormsModule } from "@angular/forms";
+
@NgModule({
declarations: [],
- imports: [AppRoutingModule, ComponentsModule, FormsModule, CommonModule],
+ imports: [],
exports: [AppRoutingModule, ComponentsModule, FormsModule, CommonModule],
})
export class PublicModule {}
diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html
index 9ca3524..4ccdf84 100644
--- a/src/app/pages/home/home.component.html
+++ b/src/app/pages/home/home.component.html
@@ -4,7 +4,7 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:06:15
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-09 10:55:03
+ * @LastEditTime: 2022-03-09 14:01:40
-->
@@ -15,10 +15,14 @@
-
+
diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts
index 6c779be..7c88865 100644
--- a/src/app/pages/home/home.component.ts
+++ b/src/app/pages/home/home.component.ts
@@ -4,12 +4,13 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:06:15
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-08 14:38:05
+ * @LastEditTime: 2022-03-09 13:47:01
*/
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
import { RequestService } from "src/app/services/request.service";
// 引入服务
import { StorageService } from "src/app/services/storage.service";
+import { ActivatedRoute } from "@angular/router";
@Component({
selector: "app-home",
templateUrl: "./home.component.html",
@@ -18,7 +19,12 @@ import { StorageService } from "src/app/services/storage.service";
export class HomeComponent implements OnInit {
@ViewChild("homeHead", { static: true }) homeHead: any;
public result: any = "";
- constructor(public storage: StorageService, public request: RequestService) {}
+ public key: string = "123";
+ constructor(
+ public storage: StorageService,
+ public request: RequestService,
+ public route: ActivatedRoute
+ ) {}
// init结尾的函数只会调用一次 checked结尾的函数会多次调用
// 初始化组件和指令时调用(一般用于请求api)
ngOnInit(): void {
diff --git a/src/app/pages/home/home.module.ts b/src/app/pages/home/home.module.ts
index 6f713d5..06a9eed 100644
--- a/src/app/pages/home/home.module.ts
+++ b/src/app/pages/home/home.module.ts
@@ -4,13 +4,14 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:06:01
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-09 11:54:23
+ * @LastEditTime: 2022-03-09 13:39:03
*/
import { NgModule } from "@angular/core";
import { HomeComponent } from "./home.component";
import { HeadComponent } from "./components/head/head.component";
import { BodyComponent } from "./components/body/body.component";
import { PublicModule } from "src/app/model/public.module";
+
@NgModule({
declarations: [HomeComponent, HeadComponent, BodyComponent],
imports: [PublicModule],
diff --git a/src/app/pages/user/user.component.html b/src/app/pages/user/user.component.html
index 3e01196..32af0b2 100644
--- a/src/app/pages/user/user.component.html
+++ b/src/app/pages/user/user.component.html
@@ -4,13 +4,15 @@
* @Author: Ruin 🍭
* @Date: 2022-03-04 10:45:56
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-09 10:56:33
+ * @LastEditTime: 2022-03-09 13:23:58
-->
user works!
-
跳转回主页
+
跳转回主页
+
+
跳转
diff --git a/src/app/pages/user/user.component.ts b/src/app/pages/user/user.component.ts
index b558f4e..201eefd 100644
--- a/src/app/pages/user/user.component.ts
+++ b/src/app/pages/user/user.component.ts
@@ -4,20 +4,33 @@
* @Author: Ruin 🍭
* @Date: 2022-03-04 10:45:56
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-08 17:32:59
+ * @LastEditTime: 2022-03-09 13:59:01
*/
import { Component, OnInit } from "@angular/core";
+import { ActivatedRoute } from "@angular/router";
import { AxiosService } from "src/app/services/axios.service";
import { RequestService } from "src/app/services/request.service";
+
@Component({
selector: "app-user",
templateUrl: "./user.component.html",
styleUrls: ["./user.component.scss"],
})
export class UserComponent implements OnInit {
- constructor(public httpApi: RequestService, public axiosApi: AxiosService) {}
+ constructor(
+ public httpApi: RequestService,
+ public axiosApi: AxiosService,
+ public route: ActivatedRoute
+ ) {}
public list: any;
- ngOnInit(): void {}
+ ngOnInit(): void {
+ this.route.queryParams.subscribe((params) => {
+ console.log("路由传过来的参数", params);
+ });
+ // this.route.params.subscribe((params) => {
+ // console.log("动态路由路径", params);
+ // });
+ }
// async getApiData() {
// try {
// let res: any = await this.httpApi.getRequest();
diff --git a/src/app/pages/user/user.module.ts b/src/app/pages/user/user.module.ts
index 0eb3d7e..a351d11 100644
--- a/src/app/pages/user/user.module.ts
+++ b/src/app/pages/user/user.module.ts
@@ -4,7 +4,7 @@
* @Author: Ruin 🍭
* @Date: 2022-03-04 10:42:33
* @LastEditors: 刘引
- * @LastEditTime: 2022-03-09 11:56:39
+ * @LastEditTime: 2022-03-09 13:38:45
*/
import { NgModule } from "@angular/core";
import { InfoComponent } from "./components/info/info.component";
diff --git a/src/styles.scss b/src/styles.scss
index 37d53c4..8c613aa 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -4,3 +4,6 @@
margin: 0;
padding: 0;
}
+.active {
+ color: red;
+}