08 2021 档案
摘要:TypeScript的泛型 泛型的概念 如果希望实现函数的返回值类型与参数类型一致,可以这样写: function fun(arg: string): string { return arg } 或者这样: function fun(arg: number): number { return arg
阅读全文
摘要:TypeScript的联合类型 联合类型指的是一个变量有多种可能的类型,多种类型间用符号|分割 let content: string | number = "content"; // content 既可以是字符串,也可以是数字 content = 123; TypeScript的类型保护 as
阅读全文
摘要:TypeScript的类 类的基本使用 新建文件demo.ts,写入以下内容: class Father { content = "我是你父亲!"; say() { return this.content; } } let father = new Father(); console.log(fat
阅读全文

浙公网安备 33010602011771号