【发布时间】:2019-02-22 04:12:48
【问题描述】:
//parent class
module.exports = class Parser {
constructor() {}
tokenize(s) {}
fixDates(rule) {}
}
//child class
const Parser = require('./parser');
module.exports = class ParserEn extends Parser {
constructor() {}
run(str) {
super.tokenize(str.toLowerCase()).forEach(function (s) {
//here i want to acces to another function in the parent class
super.fixDates(rule); //I get this error: 'super' keyword unexpected here
});
}
}
嗨, 正如您在上面的代码中看到的,我在父类中有两个函数,在子类中有一个函数。在子类中的运行函数中,我可以使用关键字“super”访问tokenize。但是,我也需要访问 fixDates 函数,但我确实收到此错误: "'super' keyword unexpected here" 。如果有人帮助我,那就太好了。提前致谢
【问题讨论】:
标签: javascript node.js class superclass