[英]TypeScript interface: how to declare a property of Array type?
我有以下界面:
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
}
我似乎在文檔中找不到這個。 如何將該屬性正確放入接口中?
請參閱TypeScript基本類型 :
export interface ITransaction {
...
tags: string[]
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.