我在all.ts
模块中有几个类:
export class TemperatureSensor {
temperature: number;
}
export class Chasis {
id: string;
type: string;
ambientTemperature: TemperatureSensor
}
export class Computer {
model: string;
serial: string;
chasis: Chasis;
}
在另一个模块中,我需要导入所有它们-我使用
import * as models from 'all';
我可以new models.Computer()
以示例为例访问类。
问题:如何在all.ts
没有名称空间的情况下导入所有类?所以我想用new Computer()
?
您可以按如下方式解构
import * as models from 'all';
const {Computer} = models;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句