【问题标题】:Simplifying the imports and exports with Typescript使用 Typescript 简化导入和导出
【发布时间】:2022-07-20 23:11:14
【问题描述】:

所以我是 JS 和 TS 的新手,不是那么新,而是有点,所以我正在像这样导出我的组件,并且列表一天比一天大。

import Notification from "./Notification";
import Confirmation from "./Confirmation";
import Button from './Button';
import Input from './Input';
import Dropdown from "./Dropdown";
import Add from "./Add";


export {
    Notification,
    Confirmation,
    Button,
    Input,
    Dropdown,
    Add,

}

我想知道如何使用 vanilla JS 或 TS 更好地构建它。

【问题讨论】:

    标签: typescript


    【解决方案1】:

    在您的index.ts/index.js 文件中,您可以执行export .. from "..."(其中... 是默认导入或命名导入,... 是文件路径)

    export Notification from "./Notification";
    export Confirmation from "./Confirmation";
    export Button from './Button';
    export Input from './Input';
    export Dropdown from "./Dropdown";
    export Add from "./Add";
    

    【讨论】:

      猜你喜欢
      • 2015-05-08
      • 2019-05-20
      • 1970-01-01
      • 2015-08-23
      • 2017-01-22
      • 2016-11-01
      • 2021-12-19
      • 1970-01-01
      • 2021-10-14
      相关资源
      最近更新 更多