Eve*_*tos 26 extends implements typescript
我能用打字稿做这个吗?
export interface IMyInterface {
doSomething():void;
}
export class MyBaseClass {
myBaseClassHasProperty:string;
constructor(){
this.myBaseClassHasProperty = 'some value';
}
myBaseClassHasMethods():void{
console.log(this.myBaseClassHasProperty);
}
}
export class MyClass extends MyBaseClass implements IMyInterface {
constructor(){
super();
}
doSomething():void{
this.myBaseClassHasMethods();
}
}
Run Code Online (Sandbox Code Playgroud)
在运行时我得到这个
未捕获的ReferenceError:未定义MyBaseClass
bas*_*rat 17
在运行时我得到这个
Uncaught ReferenceError: MyBaseClass is not defined
是的,你可以这样做.您发布的代码将正常工作.
不过我在怀疑你的实际代码你拥有了它拆分到多个文件,MyBaseClass是不执行的代码之前MyClass.
修复JavaScript排序或使用外部模块以使模块加载器确定排序.
| 归档时间: |
|
| 查看次数: |
20205 次 |
| 最近记录: |