Skip to content

为什么引入Module的时候路径明明是Button/index.js,却可以用import Button from 'Button' #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zhouzhongyuan opened this issue Feb 23, 2017 · 0 comments

Comments

@zhouzhongyuan
Copy link
Owner

zhouzhongyuan commented Feb 23, 2017

为什么引入Module的时候路径明明是Button/index.js,却可以用import Button from 'Button'
这是ES6的特殊写法吗?

答:

不是。这是模块加载器的工作,ES6没有规定任何和模块加载相关的规范。

这是Nodejs模块加载器所支持的写法,Webpack等为了兼容性也支持这种写法。

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant