导出导入的模块 [英] Export an imported module

查看:183
本文介绍了导出导入的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个javascript模块,如下所示:

I have two javascript modules that looks like this:

// inner/mod.js
export function myFunc() {
   // ...
}

// mod.js
import * as inner from "./inner/mod";

我想将 myFunc code> mod.js 。我该怎么做?

I would like to export myFunc from mod.js. How can I do this?

编辑:我应该澄清一点,该功能正在从 inner / mod.js 中预期导出,但我也要从外部 mod.js 导出功能。

I should clarify that the function is being exported as expected from inner/mod.js but I also want to export the funtion from the outer mod.js.

对于要求澄清的人,我想实现这一点:

To those asking for clarification, I would like to achieve this:

// SomeOtherFile.js
import * as mod from "mod"; // NOT inner/mod

mod.myFunc();


推荐答案

我相信你正在寻找的是

export * from './inner/mod';

这将重新导出 ./ inner / mod spec 具有实际上是一个非常好的表,列出所有可能的导出导入变体。

That will reexports all exports of ./inner/mod. The spec has actually a very nice table, listing all the possible export and import variants.

这篇关于导出导入的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆