赞
踩
import { Component, OnInit } from ‘@angular/core’;
import { StorageService } from ‘src/app/services/storage.service’;
@Component({
selector: ‘app-search’,
templateUrl: ‘./search.component.html’,
styleUrls: [‘./search.component.scss’],
})
export class SearchComponent implements OnInit {
public keyword = ‘’;
public historyList = [];
constructor(public storageService: StorageService) {}
ngOnInit(): void {
const searchList = this.storageService.get(‘searchList’);
if (searchList) {
this.historyList = searchList;
}
}
public doSearch(): void {
if (this.historyList.indexOf(this.keyword) === -1) {
this.historyList.unshift(this.keyword);
// 这个地方传入的是一个数组, 在set中需要转成json, 在get中需要解析成数组拿出来
this.storageService.set(‘searchList’, this.historyList);
this.keyword = ‘’;
}
}
public onDelete(index: number): void {
this.historyList.splice(index, 1);
this.storageService.set(‘searchList’, this.historyList);
}
}
实现效果如图:
功能概述: 在第一例的基础上, 我们还可以通过点击checkBox来实时更改数据状态
HTML:
<input type=“text” [(ngModel)]=“keyword” (keyup)=“doAdd($event)” />
<input type=“checkbox” [(ngModel)]=“item.status” (change)="changeCheckBox() "/>{{ item.title }}
<button (click)=“onDelete(i)”>×
<input type=“checkbox” [(ngModel)]=“item.status” (change)=“changeCheckBox()” />{{ item.title }}
<button (click)=“onDelete(i)”>×
CSS:
h2{
text-align: center;
}
.toDoList{
margin: 20px auto;
width: 400px;
li{
line-height: 60px;
}
}
TS:
import { Component, OnInit } from ‘@angular/core’;
import { StorageService } from ‘…/…/services/storage.service’;
@Component({
selector: ‘app-to-do-list’,
templateUrl: ‘./to-do-list.component.html’,
styleUrls: [‘./to-do-list.component.scss’],
})
export class ToDoListComponent implements OnInit {
public toDoData = [];
public keyword = ‘’;
public status = false;
constructor(public storageService: StorageService) {}
ngOnInit(): void {
const storageToDoList = this.storageService.get(‘toDoList’);
if (storageToDoList) {
this.toDoData = storageToDoList;
}
}
public doAdd(e: any): void {
if (e.keyCode === 13) {
if (this.toDoDataHasKeyWord(this.toDoData, this.keyword)) {
this.toDoData.push({ title: this.keyword, status: this.status });
this.keyword = ‘’;
this.storageService.set(‘toDoList’, this.toDoData);
}
}
}
public onDelete(key: number): void {
this.toDoData.splice(key, 1);
this.storageService.set(‘toDoList’, this.toDoData);
}
public toDoDataHasKeyWord(toDoData: any[], keyword: any): boolean {
// 异步问题先不用
// this.toDoData.forEach((item) => {
// });
return !toDoData.some((item) => item.title === keyword);
// const { length } = toDoData;
// for (let i = 0; i < length; ++i) {
// if (toDoData[i].title === keyword) {
// return false;
// }
// }
// return true;
// }
}
public changeCheckBox(): void {
this.storageService.set(‘toDoList’, this.toDoData);
}
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)
回顾项目
往往在面试时,面试官根据你简历中的项目由点及面地展开问答,所以请对你做过的最好的项目进行回顾和反思。回顾你做过的工作和项目中最复杂的部分,反思你是如何完成这个最复杂的部分的。
面试官会重点问你最复杂的部分的实现方法和如何优化。重点要思考如何优化,即使你项目中没有对那部分进行优化,你也应该预先思考有什么优化的方案。如果这部分答好了,会给面试官留下很不错的印象。
重点在于基础知识
这里指的基础知识包括:前端基础知识和学科基础知识。
前端基础知识:html/css/js 的核心知识,其中 js 的核心知识尤为重要。比如执行上下文、变量对象/活动对象(VO/AO)、作用域链、this 指向、原型链等。
学科基础知识:数据结构、计算机网络、算法等知识。你可能会想前端不需要算法,那你可能就错了,在大公司面试,面试官同样会看重学生这些学科基础知识。
你可能发现了我没有提到React/Vue
这些框架的知识,这里得说一说,大公司不会过度的关注这方面框架的知识,他们往往更加考察学生的基础。
这里我的建议是,如果你至少使用或掌握其中一门框架,那是最好的,可以去刷刷相关框架的面试题,这样在面试过程中即使被问到了,也可以回答个 7788。如果你没有使用过框架,那也不需要太担心,把重点放在基础知识和学科基础知识之上,有其余精力的话可以去看看主流框架的核心思想。
/js 的核心知识,其中 js 的核心知识尤为重要。比如执行上下文、变量对象/活动对象(VO/AO)、作用域链、this 指向、原型链等。
学科基础知识:数据结构、计算机网络、算法等知识。你可能会想前端不需要算法,那你可能就错了,在大公司面试,面试官同样会看重学生这些学科基础知识。
你可能发现了我没有提到React/Vue
这些框架的知识,这里得说一说,大公司不会过度的关注这方面框架的知识,他们往往更加考察学生的基础。
这里我的建议是,如果你至少使用或掌握其中一门框架,那是最好的,可以去刷刷相关框架的面试题,这样在面试过程中即使被问到了,也可以回答个 7788。如果你没有使用过框架,那也不需要太担心,把重点放在基础知识和学科基础知识之上,有其余精力的话可以去看看主流框架的核心思想。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。