Answers:
这是将参数标记为可选。
这是为了使变量成为Optional类型。否则,如果不使用此变量,则声明的变量将显示“ undefined ”。
export interface ISearchResult {
title: string;
listTitle:string;
entityName?: string,
lookupName?:string,
lookupId?:string
}
title在上面的示例中,值为仍然是有效的,null但是对于声称要实现的类在编译时ISearchResult缺少entityName属性将是无效的。
string?。要具有可选的nullable,您可以这样做name?: string?。
?type 放在类型说明之后而不是在变量名之后会更有意义。如果您不传递任何东西lookupId,它将没有类型string。
parameter?: type 是的简写 parameter: type | undefined