search

Home  >  Q&A  >  body text

javascript - What is the difference between adding {} after webpack import module and not adding curly brackets?

What is the difference between import a from 'b' and import {a} from 'b'

大家讲道理大家讲道理2758 days ago1304

reply all(4)I'll reply

  • 迷茫

    迷茫2017-07-05 10:44:24

    MDN
    You can find these conceptual questions by yourself by searching on mdn

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我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.

    reply
    0
  • typecho

    typecho2017-07-05 10:44:24

    Object destructuring and assignment
    Owner, you need to understand the commonly used ES6 features.

    reply
    0
  • 迷茫

    迷茫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.

    reply
    0
  • Cancelreply