我需要将接口属性映射到对象:
interface Activity {
id: string,
title: string,
body: string,
json: Object
}
我现在有:
headers: Array<Object> = [
{ text: 'id', value: 'id' },
{ text: 'title', value: 'title' },
{ text: 'body', value: 'body' },
{ text: 'json', value: 'json' }
]
这是非常重复的,我想要的是这样的:
headers: Array<Object> = Activity.keys.map(key => {
return { text: key, value: key }
})