The difference between export default and export in es6

export and import (one export and one import)
export of export, you need to use curly braces when importing, and the name must be the same as that of export, that is, you have to know its
name. Start whatever you want without knowing its name

export
a.js
function a() { } export {a} or export function a() { } b.js import {a} from "a" //Fill in the path according to your actual situation. {a} The name cannot be changed,                                if If you want to change the name, you have to use as, import {n as a} from "a"                                or import * as names from "a" will combine the exported content of several exports into one object and return it. Such writing will lead to unnecessary introduction and affect performance ,








export default
c.js
function c() {
}
export default  c
或者
export default function c() {
}
d.js
import  name from "a" 


In a file or module, there can be multiple export and import, and only one export default, which means the following code:

var name1="aa";
var name2="bb";
export { name1 ,name2 }
或者
 export name1;
 export name2;

var test = "AA";
export default test 
is actually equivalent to a system default variable name default for the test variable value "AA". Naturally default can only have one value, so there cannot be multiple export defaults in a file .

------------------Dividing line------------------------------ -------------------------------------------------- ----
Because of the separation of the front and back ends of vue, if there are any errors, please feel free to raise them~

Guess you like

Origin blog.csdn.net/CarryBest/article/details/88820644