Vue difference in export and export default of

I believe many people have used export in vue, export default, import, however they are in the end what difference does it make? 

  In the ES6, Expor T and export default can be used to derive constants, functions, files, modules , etc., you can in other files or modules in the  embodiment, it is introduced, so that it can be used, but a file or modules, export, import can have multiple, export default only one .import + (常量 | 函数 | 文件 | 模块)名

export use: 

//demo1.js
export const str = 'hello world'
 
export function f(a){
    return a+1
}

Import corresponding manner:

// demo2.js 
Import {STR, F} from  ' the demo1 '  // can write two separate, when introduced with braces

export default used

//demo3.js
export default const str = 'hello world'

Import corresponding manner:

// demo4.js 
Import str from  ' demo1 '  // when no import braces

 

Guess you like

Origin www.cnblogs.com/ysx215/p/10972087.html