结尾
正式学习前端大概 3 年多了,很早就想整理这个书单了,因为常常会有朋友问,前端该如何学习,学习前端该看哪些书,我就讲讲我学习的道路中看的一些书,虽然整理的书不多,但是每一本都是那种看一本就秒不绝口的感觉。
以下大部分是我看过的,或者说身边的人推荐的书籍,每一本我都有些相关的推荐语,如果你有看到更好的书欢迎推荐呀。
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
IsDate,
Min,
Max,
} from ‘class-validator’; //引入
#### 2.输出类
export class Post {
@Length(10, 20)
title: string;
@Contains(‘hello’)
text: string;
@IsInt()
@Min(0)
@Max(10)
rating: number;
@IsEmail()
email: string;
@IsFQDN()
site: string;
@IsDate()
createDate: Date;
} //导出类
#### 3.声明类并调用类中的方法进行校验
let post = new Post(); //声明一个post
post.title = ‘Hello’; // 不通过
post.text = ‘this is a great post about hell world’; // 不通过
post.rating = 11; // 不通过
post.email = ‘google.com’; // 不通过
post.site = ‘googlecom’; // 不通过
#### 4.验证监听
validate(post).then(errors => {
// errors is an array of validation errors
if (errors.length > 0) {
console.log('validation failed. errors: ', errors);
} else {
console.log(‘validation succeed’);
}
});
#### 5.错误输出
此方法返回一个validationError 对象 每一项如下
{
target: Object; // 已经验证的对象.
property: string; // 未通过验证的对象属性.
value: any; // 未通过验证的值.
constraints?: { // 验证失败并带有错误消息.
[type: string]: string;
};
children?: ValidationError[]; // Contains all nested validation errors of the property
}
#### 6.消息
在装饰器下提示指定信息
import { MinLength, MaxLength } from ‘class-validator’;
export class Post {
@MinLength(10, {
message: ‘Title is too short’,
})
@MaxLength(50, {
message: ‘Title is too long’,
})
title: string;
}
>
> 在消息中可以使用特殊的$符号
>
>
>
$value - 正在验证的值
$property - 要验证的对象属性的名称
$target - 要验证的对象的类的名称
$constraint1, $constraint2, … $constraintN - 由特定验证类型定义的约束
举个栗子 》》》》》》》》》
import { MinLength, MaxLength } from ‘class-validator’;
export class Post {
@MinLength(10, {
// here, $constraint1 会被替换为最小长度 “10”, $value 会被替换为换取的值
message: ‘Title is too short. Minimal length is $constraint1 characters, but actual is $value’,
})
@MaxLength(50, {
// here, $constraint1 will be replaced with “50”, and $value with actual supplied value
message: ‘Title is too long. Maximal length is $constraint1 characters, but actual is $value’,
})
title: string;
}
#### 7.检验数组的方法
js基础
1)对js的理解?
2)请说出以下代码输出的值?
3)把以下代码,改写成依次输出0-9
4)如何区分数组对象,普通对象,函数对象
5)面向对象、面向过程
6)面向对象的三大基本特性
7)XML和JSON的区别?
8)Web Worker 和webSocket?
9)Javascript垃圾回收方法?
10)new操作符具体干了什么呢?
11)js延迟加载的方式有哪些?
12)WEB应用从服务器主动推送Data到客户端有那些方式?
g-Gbp2tIAh-1715695435473)]
[外链图片转存中…(img-7CRh6Plk-1715695435474)]