![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
TypeScript
Y____X
尧
展开
-
接口,属性的封装,泛型
接口(function () { // 描述一个对象的类型 type myType = { name: string; age: number; [propName: string]: any; }; // type myType = {};报错 /** * 接口用来定义一个类结构,用来定义一个类中应该包含哪些属性和方法 * 同时接口也可以当成类型声明去使用 * 接口可以重复声明,所有的接口加起来合成一个 */ i原创 2021-11-23 15:25:43 · 512 阅读 · 0 评论 -
extends继承
继承(function () { //定义一个Animal类 class Animal { name: string; age: number; constructor(name: string, age: number) { this.name = name; this.age = age; } sayHello() { console.log("动物giaogiaogiao"); } } /**原创 2021-11-11 15:03:58 · 824 阅读 · 0 评论 -
class类
类基础类// 使用class关键字定义类/** * 对象中主要包含了两个部分 * 属性 * 方法 */class Person { /** * 直接定义的属性是实例属性,需要通过对象的实例去访问 * const person = new Person(); * person.name * * 使用static定义的属性是静态属性(类属性),可以直接通过类访问 * Person.gender * */原创 2021-11-11 15:02:28 · 522 阅读 · 0 评论 -
webpack打包基本配置
webpack打包基本配置安装webpack及相关基本包yarn add -D webpack webpack-cli typescript// 自动生成html文件yarn add -D html-webpack-plugin// 内置服务器,热更新yarn add -D webpack-dev-server// 每一次编译前清空distyarn add -D clean-webpack-pluginwebpack.config.js// 引入一个包const path =原创 2021-11-05 17:24:01 · 418 阅读 · 0 评论 -
tsconfig.json 编译常用配置项
编译tsc 文件 -w,文件监视,自动编译;项目根目录创建tsconfig.json文件,执行tsc,可编译项目内的全部ts文件,执行tsc -w,监视所有文件,自动编译;tsconfig.json 常用配置项{ /* tsconfig.json是ts编译器的配置文件,ts编译器可以根据它的信息来对代码进行编译 */ /* "include" 用来指定哪些ts文件需要被编译,**表示任意目录,*表示任意文件 表示根目录下的src文件下的任意目录下的任意原创 2021-11-03 16:20:24 · 154 阅读 · 0 评论 -
TypeScript学习笔记——基本类型
TypeScript学习笔记1、环境搭建1.下载安装Node.js2.npm全局安装typescript3.创建ts文件4.tsc编译or creat-react-appnpx create-react-app typescript-pro --template typescriptcd typescript-pronpm install --save typescript @types/node @types/react @types/react-dom 2、基本类型声明入门原创 2021-11-02 14:31:05 · 89 阅读 · 0 评论