在ES6中是否存在ES5的任何单线类比`module.exports = require('./ inner.js')`? [英] Is there any one-line analogy in ES6 for ES5 `module.exports = require('./inner.js')`?

查看:134
本文介绍了在ES6中是否存在ES5的任何单线类比`module.exports = require('./ inner.js')`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

// before
module.exports = require('./inner.js');
// nowadays
export default from './inner.js';

我正在尝试这样做,但是babel仅在es7阶段1中允许它,因为它是< a href =https://github.com/leebyron/ecmascript-export-default-from =noreferrer>目前提议。所以现在,我坚持这两行:

i'm trying to do this, but babel allow it only in es7 stage 1 as it is proposal for now. So for now, im stick to these two lines:

import sticker from './box-sticker.jsx';
export default sticker;

我可以将它们缩短为一个吗?

Can I shorter them to one?

推荐答案

你应该能够做到

export {default as default} from './inner.js';
// or even
export {default} from './inner.js';

当前的ES6语义。

但是我认为使用ES下一个提案没有任何问题,我非常有信心它会进入 ES7 ES8。

However I don't think there's anything wrong with using the ES next proposal, I'm pretty confident that it will make it into ES7 ES8.

这篇关于在ES6中是否存在ES5的任何单线类比`module.exports = require('./ inner.js')`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆