javascript - What is the difference between adding {} after webpack import module and not adding curly brackets?
大家讲道理
大家讲道理 2017-07-05 10:42:24
0
4
1284

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

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(4)
迷茫

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

女神的闺蜜爱上我

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.

typecho

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

迷茫

The difference is that the first one is exported through export default, and the second one is exported through export.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template