How to declare an object whose properties are of type string only using TypeScript?

前端 未结 3 780
遥遥无期
遥遥无期 2021-01-29 04:21

I have a configuration array in my component like this.

...
config: ButtonConfig[];
...
this.config.push(new ButtonConfig(...));
...

Today, I r

3条回答
  •  醉梦人生
    2021-01-29 04:39

    const btn: {[keys: string]: string} = {
        key: 'value',
        anotherKey: 'anotherValue'
    }
    

    This example should help you.

提交回复
热议问题