Import * as xxx from 'Xxx ' and Import xxx from 'xxx' ? At the same time, in vuex, why can you use var xxx= require('Xxx ') instead of the second writing method, but not the first one?
In addition to specifying a certain output value to load, you can also use overall loading, that is, use an asterisk (*) to specify an object, and all output values will be loaded on this object.
The writing method of import is related to the export of the module you import
According to the picture above, import xxx from 'XXX' is to name the export default in XXX as xxx in this module, and var xxx = require('XXX'); is also to name the export default in XXX in this module. The module is named xxx, so it can be replaced; import * as xxx from 'XXX'; means that all exports in XXX are named xxx in this module, and there is export function A(){...} in XXX. You can use xxx.A() to reference.
First question:
In addition to specifying a certain output value to load, you can also use overall loading, that is, use an asterisk (*) to specify an object, and all output values will be loaded on this object.
Here is one
circle.js
文件,它输出两个方法area
和circumference。
Now, load this module.
The above writing method is to specify the methods to be loaded one by one. The overall loading method is as follows.
The ECMAScript6 book from Ruan Yifeng
I hope the poster can understand it
You can read this article
http://es6.ruanyifeng.com/#do...
The writing method of import is related to the export of the module you import
According to the picture above, import xxx from 'XXX' is to name the export default in XXX as xxx
in this module, and var xxx = require('XXX'); is also to name the export default in XXX in this module. The module is named xxx, so it can be replaced;
import * as xxx from 'XXX'; means that all exports in XXX are named xxx in this module, and there is export function A(){...} in XXX. You can use xxx.A() to reference.