[英]does typescript interface property can't use “-”?
I try to use interface to case an http header, like this: 我尝试使用接口来设置http标头,例如:
interface httpHeader {
Content-Type: string;
}
export function HTTPOptionCreate(url: string, path: string, port: number, method: string, header: httpHeader) {
....
}
But it report: 但它报告:
error|
错误| 1131[QF available]: Property or signature expected.
1131 [可用的QF]:应该是属性或签名。
I guess(Because I can't find in typescript handbook) interface can't use "-", because when I delete "-" it will be all fine. 我猜(因为我在打字稿手册中找不到)界面不能使用“-”,因为当我删除“-”时就可以了。
And if I am right, how can I case a JSON like variable in Typescript? 如果我是对的,我该如何在Typescript中加上JSON之类的变量? Thanks a lot!
非常感谢!
Change 更改
interface httpHeader {
Content-Type: string;
}
To quoted string: 引用字符串:
interface httpHeader {
'Content-Type': string;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.