我有两个 javascript 模块,如下所示:
// inner/mod.js
export function myFunc() {
// ...
}
// mod.js
import * as inner from "./inner/mod";
我想出口myFunc
from mod.js
。我怎样才能做到这一点?
编辑:我应该澄清该函数正在按预期导出inner/mod.js
但我也想从外部导出该函数mod.js
.
对于那些要求澄清的人,我希望实现这一目标:
// SomeOtherFile.js
import * as mod from "mod"; // NOT inner/mod
mod.myFunc();
我相信你正在寻找的是
export * from './inner/mod';
这将再出口所有出口./inner/mod
. The spec http://www.ecma-international.org/ecma-262/6.0/index.html#sec-source-text-module-records实际上有非常好的表格列出了所有可能的import http://www.ecma-international.org/ecma-262/6.0/index.html#table-40 and export http://www.ecma-international.org/ecma-262/6.0/index.html#table-42变体。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)