【问题标题】:export {x as x} does not work with babeljsexport {x as x} 不适用于 babeljs
【发布时间】:2015-07-21 21:14:08
【问题描述】:

当我尝试导入模块时,为什么 pattern 会以 undefined 结束:

export {machines as machines} from './machines';

【问题讨论】:

  • 你是如何从./machines导出的?
  • 就像这样:export default function machines(state, action) {}

标签: javascript babeljs


【解决方案1】:

如果你在做

export default function machines(state, action) {} 

那么你有一个default 导出,而不是named 导出。 export default 导出任意表达式,您的函数具有名称 machines 的事实对导出行为没有影响。对于那种格式,你会这样做

export {default as machines} from './machines';

使用您的问题中的export ... from 格式,您的导出必须是:

export function machines(state, action) {} 

【讨论】:

    猜你喜欢
    • 2017-01-09
    • 2017-03-25
    • 1970-01-01
    • 1970-01-01
    • 2021-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多