打字稿 - [字符串] 与字符串 [] [英] TypeScript - [string] vs string[]

查看:27
本文介绍了打字稿 - [字符串] 与字符串 []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在打字稿中,什么是正确的?

In typescript, What is right thing?

[字符串] vs 字符串[]

[string] vs string[]

public searchOption: [string] = ['date'];
public searchOption: string[] = ['date'];

推荐答案

第二个是对的.如果你愿意,你可以看看这里 https://www.typescriptlang.org/docs/handbook/basic-types.html

The second one is right. If you want, you can take a look here https://www.typescriptlang.org/docs/handbook/basic-types.html

这篇关于打字稿 - [字符串] 与字符串 []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆