Javascript 从其他导出调用默认模块导出?

Javascript 从其他导出调用默认模块导出?,javascript,ecmascript-6,es6-modules,Javascript,Ecmascript 6,Es6 Modules,假设您有此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; } exp

假设您有此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;
}

您可以给它命名,它将在范围内:

export default function foo(txt) {
    // Do something with txt
    return txt;
}

export function bar(txt) {
    txt = foo(txt);
    return txt;
}

您可以创建函数,然后将其导出,也可以只命名函数

export default function myDefault () {
  // code
}

export function doSomething () {
  myDefault()
}


您可以创建函数,然后将其导出,也可以只命名函数

export default function myDefault () {
  // code
}

export function doSomething () {
  myDefault()
}


尝试导出对函数的引用:

var theFunc = function(txt)
{
// Do something with txt
return txt;
}

export default theFunc

然后您可以在其他地方引用函数。

尝试导出对函数的引用:

var theFunc = function(txt)
{
// Do something with txt
return txt;
}

export default theFunc
然后您可以在其他地方引用Func