我有一个班级:
class Dice {
div: Element;
value: string;
constructor(div: Element) {
this.div = div;
}
}
我diceRoller
类扩展了Dice
类:
class diceRoller extends Dice {
static Values = Values;
constructor(div: Element) {
super(div);
(this.div as HTMLElement).style.width = diceSize;
(this.div as HTMLElement).style.height = diceSize;
(this.div as HTMLElement).style.textAlign = 'center';
(this.div as HTMLElement).style.lineHeight = diceSize;
(this.div as HTMLElement).style.border = diceBorder;
(this.div as HTMLElement).style.marginRight = '10px';
(this.div as HTMLElement).style.cssFloat = 'left';
}
changeValue(val: number): boolean {
this.value = Values[val];
(this.div as HTMLElement).innerHTML = this.value;
return true;
}
}
如何将diceRoller
类转换为模块。我已经在TypeScript手册中尝试过,但我还没想到。
答案 0 :(得分:0)
我想用类似于export {new diceRoller(div:Element)}的形式导出类,因为我想将一个参数传递给我导入模块的文件中的类。所以,究竟什么是形式
简单地说:
export const foo = new diceRoller(div);