我正在尝试在扩展类中使用扩展类的方法(这可能不是很清楚,但是请看下面的示例,您将会理解)。
我的模块是用打字稿制作的:
export default class Test1 {
private storedCond: string;
public cond = (cond: string) => {
this.storedCond = cond;
return this.storedCond.length;
};
public getStoredCond = () => this.storedCond;
}
然后我想使用的是js文件中的某些方式:
import Test1 from './modules/Test1';
class Test2 extends Test1 {
// this line is not working, how can i make it work ?
this.cond('a futur dynamic string');
final = () => `${this.getStoredCond()} is ${this.getStoredCond().length} length`;
}
const test = new Test2();
console.log(test.final());
我的Test1模块有点像商店,我可以做这样的事情:sotredCond = this.cond('a futur dynamic string');在我的Test2课上,但这不是我想要做的。我想cond在我的Test2课程中提供一个字符串()并将其存储在我的Test1模块中。
守着星空守着你
相关分类