我有两个文件中的两个类.
//a.ts
export class A{}
//b.ts
export class B{}
如何构建文件c.ts
,从中导入这两个类?
import {A, B} from "c";
而不是
import {A} from "a";
import {B} from "b";
我想做一种出口门面.
我有两个文件中的两个类.
//a.ts
export class A{}
//b.ts
export class B{}
如何构建文件c.ts
,从中导入这两个类?
import {A, B} from "c";
而不是
import {A} from "a";
import {B} from "b";
我想做一种出口门面.
我自己找到了答案
https://www.typescriptlang.或g/docs/handbook/modules.html@转口
做我想做的事的代码
//c.ts
exp或t {A} from "a";
exp或t {B} from "b";
Default exp或t
假设你有文件
//d.ts
exp或t default class D{}
再出口必须是这样的
//reexp或t.ts
exp或t { default } from "d";
或
//reexp或t.ts
exp或t { default as D } from "d";
What happens here is that you're saying "I want to re-exp或t the default exp或t
of module "D" but with the name of D