typescript 如何在打字稿中将变量声明为字符串数组列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42566084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:18:22  来源:igfitidea点击:

How to declare a variable as list of string array in typescript

angulartypescript

提问by test

I am currently using angular 2.0 and in typescript file I want to declare a variable which is a list of string array. I am doing something like this yAxis_val: list which is not working.

我目前正在使用 angular 2.0,并且在打字稿文件中我想声明一个变量,它是一个字符串数组列表。我正在做这样的事情 yAxis_val: list 这不起作用。

Please let me know the correct way to do it.

请让我知道正确的方法。

回答by Teddy Sterne

You can define a string array as follows:

您可以按如下方式定义字符串数组:

public yAxis_val: string[][];

To initialize you would do:

要初始化,您将执行以下操作:

public yAxis_val: string[][] = [];

回答by Eduardo Dennis

There is no List data structure in typescript. You would use arrays.

typescript 中没有 List 数据结构。你会使用数组。

private yAxisVal: string[][]