Javascript Extendend类在子方法和父方法之间移动
只是一个简单的问题 我扩展了一个类,它不是我的,我需要使用YamlDataSource中的一些函数Javascript Extendend类在子方法和父方法之间移动,javascript,node.js,Javascript,Node.js,只是一个简单的问题 我扩展了一个类,它不是我的,我需要使用YamlDataSource中的一些函数 class PersistenceDataSource extends YamlDataSource { constructor() { super(); this._ = this; } 问题是:我需要使用一个只知道函数反弹的管理器,例如fetchAll 所以我需要在PersistenceDataSouce中使用它,但我还需要调用在YamlDa
class PersistenceDataSource extends YamlDataSource {
constructor() {
super();
this._ = this;
}
问题是:我需要使用一个只知道函数反弹的管理器,例如fetchAll
所以我需要在PersistenceDataSouce中使用它,但我还需要调用在YamlDataSouce中实现的那个
如果我这样做,PersistenceDataSource中的fetchAll函数将被激发,因此我想用我在构造函数中制作的解决方案来解决它,这是一个好的解决方案吗?您可以使用super.METHOD,就像使用super调用构造函数一样
因此:
async fetchAll(config) {
super.fetchAll(); // This will call the extended class fetchAll method (YamlDataSource fetchAll) instead of this class one.
});
async fetchAll(config) {
super.fetchAll(); // This will call the extended class fetchAll method (YamlDataSource fetchAll) instead of this class one.
});