假设你有这个 ES6 模块:
// ./foobar.js
export default function(txt)
{
// Do something with txt
return txt;
}
是否可以向同一个文件添加另一个函数导出,使用这个默认函数?我认为这是可能的,但你怎么调用它?
// ./foobar.js
export default function(txt)
{
// Do something with txt
return txt;
}
export function doSomethingMore(txt)
{
txt = // ? how to call default function ?
// Do something more with txt
return txt;
}
最佳答案
你可以给它起个名字,它就会在范围内:
export default function foo(txt) {
// Do something with txt
return txt;
}
export function bar(txt) {
txt = foo(txt);
return txt;
}
关于javascript - 从其他导出调用默认模块导出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47602977/