我是Typescript的新手,不知道怎么说这个问题.
我需要访问构造函数中传递的对象的两个"可能"属性.我知道我缺少一些检查以确定它们是否已定义,但是Typescript正在向我抛出"'对象'上不存在属性"消息.消息显示在选择器上,模板返回.
class View {
public options:Object = {};
constructor(options:Object) {
this.options = options;
}
selector ():string {
return this.options.selector;
}
template ():string {
return this.options.template;
}
render ():void {
}
}
Run Code Online (Sandbox Code Playgroud)
我确信它相当简单,但是Typescript对我来说是新的.