- 通过对象获取其 类型名称
export class child { constructor() { } } const p = new child() console.log(p.constructor.name) //child
- 接口,可索引属性值
export interface CC { [pro: string]: string } const bb: CC = { name: "xiaohong", age: "13" } bb.country = "zhongguo" bb.city = "beijing" bb["cun"] = "jin" console.log(Object.keys(bb)) //[ 'name', 'age', 'country', 'city', 'cun' ]
ts 相关积累
于 2022-01-28 12:13:47 首次发布