小编Dha*_*hni的帖子

如何迭代 Typescript 类中的所有属性及其值

如何迭代类属性列表并获取每个属性的值(仅属性而不是函数)

class Person{
 name:string;
 age:number;
 address:Address;
 getObjectProperties(){
   let json = {};
    // I need to get the name, age and address in this JSON and return it
    // how to do this dynamically, rather than getting one by one 
    // like json["name"] = this.name;
   return json;
 }
}
Run Code Online (Sandbox Code Playgroud)

请帮忙。

object-properties typescript

5
推荐指数
1
解决办法
8477
查看次数

标签 统计

object-properties ×1

typescript ×1