This commit is contained in:
Ruin
2022-03-07 10:31:07 +08:00
parent c6df0ef581
commit 8ddedf704a
6 changed files with 87 additions and 7 deletions

View File

@@ -4,9 +4,8 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:06:15
* @LastEditors: 刘引
* @LastEditTime: 2022-03-04 15:53:16
-->
* @LastEditTime: 2022-03-07 08:58:41
-->
<!-- <app-news></app-news> -->
<!-- <app-head></app-head> -->
<!-- <app-news></app-news> -->

View File

@@ -1,5 +1,16 @@
/*
* @Description: {{ByRuin}}
* @Version: 2.0
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:06:15
* @LastEditors: 刘引
* @LastEditTime: 2022-03-07 10:20:44
*/
import { Component, OnInit } from "@angular/core";
// 引入服务
import { StorageService } from "src/app/services/storage.service";
// 实例化类
// let storage = new StorageService();
@Component({
selector: "app-home",
templateUrl: "./home.component.html",
@@ -7,7 +18,22 @@ import { Component, OnInit } from "@angular/core";
})
export class HomeComponent implements OnInit {
public textContent: any;
constructor() {}
// 依赖注入 语法糖写法 相当于在构造器中 实例化对象
constructor(public storage: StorageService) {
// let res = storage.getTest();
let key: string = "cat";
let value: string = "hello";
// 设置缓存
storage.setStorage(key, value);
// 获取缓存
let result = storage.getStorage(key);
// 删除缓存
storage.removeStorage(key);
console.log(result);
// 清除所有缓存
storage.clearStorage();
// console.log(res);
}
ngOnInit(): void {}
changeKeyword() {

View File

@@ -4,7 +4,7 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:06:01
* @LastEditors: 刘引
* @LastEditTime: 2022-03-04 15:42:19
* @LastEditTime: 2022-03-07 10:19:20
*/
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";

View File

@@ -4,15 +4,18 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:03:51
* @LastEditors: 刘引
* @LastEditTime: 2022-03-04 15:46:33
* @LastEditTime: 2022-03-07 09:58:23
*/
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { HomeModule } from "./home/home.module";
import { UserModule } from "./user/user.module";
// 引入并且配置服务
@NgModule({
declarations: [],
imports: [CommonModule, HomeModule, UserModule],
providers: [],
exports: [CommonModule, HomeModule, UserModule],
})
export class PagesModule {}