Mr.*_*ith 5 class typescript sapui5
是否可以声明一个类具有某些功能而不实现它们?
我需要这个,因为我创建了一个类,然后将其传递给一个 js 框架,该框架添加了几个函数。我也希望能够调用这些函数,而无需重新实现它们、重定向或转换或任何其他操作。
例子:
//example class
class AppComponent {
constructor() {}
}
//create class
var comp: AppComponent = new AppComponent();
//hand over to framework
fw.define("Component", comp);
//now I want to be able to call the added functions such as:
comp.setModel(/*some model*/);
Run Code Online (Sandbox Code Playgroud)
您可以声明该函数而不实现它。
//example class
class AppComponent {
constructor() { }
setModel: () => void;
}
//create class
var comp: AppComponent = new AppComponent();
//hand over to framework
fw.define("Component", comp);
//now I want to be able to call the added functions such as:
comp.setModel(/*some model*/);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5668 次 |
| 最近记录: |