电子商务网站建设的目的,wordpress响应式网站模板,社交网站 模板,怎么做网站推广怀化一、概念定义 interface#xff1a;接口 在TS 中主要用于定义【对象类型】#xff0c;可以对【对象】的形状进行描述。type #xff1a;类型别名 为类型创建一个新名称#xff0c;它并不是一个类型#xff0c;只是一个别名。
二#xff0c;区别
interface#xff1a; …一、概念定义 interface接口 在TS 中主要用于定义【对象类型】可以对【对象】的形状进行描述。type 类型别名 为类型创建一个新名称它并不是一个类型只是一个别名。
二区别
interface interface用来定义一个类结构可以声明多个 interface myInterface{name: string;age: number;
}
interface myInterface{gender: string;
}const obj: myInterface { name: zhangsan,age: 111,gender:男
}; 使用interface声明可以被继承扩展使用 interface Inter{length: number;
}
function fn3T extends Inter(a: T): number{ return a.length;
}fn3( a: 10); type type可以定义 基本类型别名如type StringType string联合类型如 type paramType number | string;可以声明元组类型如type arrType [string, string, number]type声明可以交叉扩展 type Animal {name: string
}
type Bear Animal {honey: boolean
}