我能够使用以下方式动态访问任何给定服务的值:嵌套数组{service1: {key:value,key:value}, service2: {key:value,key:value}}
中的键
private get(service:any, key: any){
return this.getProperty(this.getProperty(this.secrets,service),key)
}
private getProperty<T, K extends keyof T>(o: T, propertyName: K): T[K] {
return o[propertyName];
但是我很难在数组中引入另一个顶层
{foo: {service1: {key:value,key:value}, service2: {key:value,key:value}}, bar: {service1: {key:value,key:value}, service2: {key:value,key:value}} }
任何快速输入吗?