我有以下界面:
export interface ITransaction {
id: number;
description: string;
category: string;
tags: array;
date: string;
amount: number;
}
显然我声明它是错误的,因为我在我的编辑器中看到一个错误。如您所见,标签应该是一个数组。这是 JSON 格式的数据:
{
"id": 1,
"description": "Sandwich",
"date": "2017-09-01",
"category": "Take away",
"tags": ["Holidays"],
"amount": -2
}
我似乎无法在文档中找到它。如何将此属性正确地放入界面中?
最佳答案
export interface ITransaction {
...
tags: string[]
...
}
关于 typescript 接口(interface) : how to declare a property of Array type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46027652/