What is the difference between import a from 'b' and import {a} from 'b'
迷茫2017-07-05 10:44:24
MDN
You can find these conceptual questions by yourself by searching on mdn
女神的闺蜜爱上我2017-07-05 10:44:24
First of all, introducing modules is ES6 syntax and has nothing to do with webpack. It's just that webpack can recognize this syntax, but nodejs doesn't support it yet.
Excerpted from MDN:
import defaultMember from "module-name"; import { member } from "module-name";
member, memberN
Name of the exported members to be imported.
defaultMember
Name which will refer to the default export from the module.
In other words, introduced through import xxx from "..."
, xxx
is already an alias of the default export item.
And import { xxx } from "..."
introduced, { xxx }
is just the name of the exported item, not the name when imported.
typecho2017-07-05 10:44:24
Object destructuring and assignment
Owner, you need to understand the commonly used ES6 features.
迷茫2017-07-05 10:44:24
The difference is that the first one is exported through export default, and the second one is exported through export.