【问题标题】:Imports difference between ES5 and ES6ES5 和 ES6 的导入区别
【发布时间】:2018-08-08 09:59:12
【问题描述】:

你如何在 ES6 中管理它?

    const withResponsiveness = require('../helpers/withResponsiveness.js').default;
    const ResponsiveLegend = withResponsiveness(Legend);

【问题讨论】:

标签: javascript ecmascript-6 ecmascript-5


【解决方案1】:

只需使用import:

import withResponsiveness from '../helpers/withResponsiveness.js';

const ResponsiveLegend = withResponsiveness(Legend);

【讨论】:

  • 没那么容易。您的导出方式也必须改变。
  • @JonasW。它已经用default 导出 - 这对于import 来说已经足够了。
  • @hsz 只要你使用 Babel / Webpack / ... 将一个转换成另一个。
  • @Toto 如果你觉得我的回答有帮助,记得采纳哦。
猜你喜欢
  • 2015-03-18
  • 2019-03-11
  • 1970-01-01
  • 2020-03-21
  • 1970-01-01
  • 2022-01-11
  • 2016-04-09
  • 2016-08-09
  • 2016-12-15
相关资源
最近更新 更多