This commit is contained in:
Ruin
2022-03-07 15:00:10 +08:00
parent 8ddedf704a
commit d9d5a69b5f
9 changed files with 40 additions and 15 deletions

View File

@@ -4,9 +4,9 @@
* @Author: Ruin 🍭
* @Date: 2022-03-03 17:06:15
* @LastEditors: 刘引
* @LastEditTime: 2022-03-07 10:20:44
* @LastEditTime: 2022-03-07 14:53:10
*/
import { Component, OnInit } from "@angular/core";
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
// 引入服务
import { StorageService } from "src/app/services/storage.service";
// 实例化类
@@ -17,6 +17,7 @@ import { StorageService } from "src/app/services/storage.service";
styleUrls: ["./home.component.scss"],
})
export class HomeComponent implements OnInit {
@ViewChild("homeHead", { static: true }) homeHead: any;
public textContent: any;
// 依赖注入 语法糖写法 相当于在构造器中 实例化对象
constructor(public storage: StorageService) {
@@ -35,11 +36,26 @@ export class HomeComponent implements OnInit {
// console.log(res);
}
ngOnInit(): void {}
// 组件和指令初始化完成(dom渲染还没有完成)
ngOnInit(): void {
// console.log("触发");
}
// dom加载完成后的生命周期函数
ngAfterViewInit(): void {
this.setDom();
}
changeKeyword() {
this.textContent = "改变keywords的值";
}
getContent() {
console.log("触发");
}
getKeyword() {
console.log(this.textContent);
}
setDom() {
this.homeHead.testViewChild();
// console.log(this.homeHead.nativeElement);
}
}