Vue Export Import imported multiple ways and distinction

There is a default keyword when using the VUE export. The difference between the corresponding IMORT WITER IMOT and partial imports in Export and Export Default are exported.

1. Partially exported and partially imported

Partial export and partial importance advantages, when the resource is relatively large, the user can use partial import to reduce resource volume, such as the Element-UI officially reducing the project volume Because the Element-UI is a very large frame, if we only use some of the components, only the components used will be imported.

 export function helloworld () {conselo.log ("Hello World");} export Function test () {ConselO.log ("this's test function");}   another way of writing, this method is not recommended, because it looks more chaotic . 
VAR HelloWorld = function () {ConselO.log (“Hello World”);} var test = function () {ConselO.log (“this’s test function”) } Export HelloWordexport Test

1.2 Part Imgent
 Import only the required resources   
Import {helloworld} from “./UTILS.JS” // only importThe method of helloWorld utils.js helloWorld (); // perform helloWorld utils.js method of

1.3 part Export – Import All
 If we need all the resources of utils.js you can import all   
import * as utils from “./utils.js” // import all resources, utils alias used utils.helloWorld (when invoked); // helloWorld method performed in utils.js utils.test (); // perform the test method utils.js

Second, all export and import all

If you use all the export, then the user must import all import, export section is recommended when writing method library, which will be fully import or partial import of power left to the user.
  2.1 Export All  
Note that: a js file can have multiple export, but only one export default

var helloWorld = function () {conselo.log ( “Hello World”);} var test = function () {conselo.log ( “this’s test function”);} export default {helloWorld, test}

2.2 import all
   
import utils from “./UTILS.JS”UTILS.HELLOWORLD( ); utils.test(); /

The above is small The various methods and distinction introductions to the Vue Export Import import, I hope to help everyone!
                    
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment