Javascript ES5和ES6之间的进口差异
在ES6中,您如何管理这一点Javascript ES5和ES6之间的进口差异,javascript,ecmascript-6,ecmascript-5,Javascript,Ecmascript 6,Ecmascript 5,在ES6中,您如何管理这一点 const withResponsiveness = require('../helpers/withResponsiveness.js').default; const ResponsiveLegend = withResponsiveness(Legend); 只需使用导入: import withResponsiveness from '../helpers/withResponsiveness.js'; const ResponsiveL
const withResponsiveness = require('../helpers/withResponsiveness.js').default;
const ResponsiveLegend = withResponsiveness(Legend);
只需使用
导入
:
import withResponsiveness from '../helpers/withResponsiveness.js';
const ResponsiveLegend = withResponsiveness(Legend);
值得注意的是:没那么容易。您的导出方式也必须改变。@JonasW。它已经用
默认值导出了
——这对于导入
@hsz来说已经足够了,只要你使用Babel/Webpack/。。。如果你觉得我的答案有帮助,记得接受它。