当前位置:网站首页>ES6 modular import and export) (realize page nesting)

ES6 modular import and export) (realize page nesting)

2022-07-26 08:53:00 sl105105

Let's first learn about exporting a obj The specific way of the object , As shown in the figure :
 
Next, we will learn which of the following import and export methods
One : Named import and Export ( We must change script Of type type :module)
First import : Using named Export :
You can export not only methods but also objects
establish Js Code , Pay attention to the form of curly brackets export export
stay html utilize Iimport Import ,from Connection address , When there are multiple exported variables , We can import not all , But the imported names should be exactly the same , No mistake .
Second import : The situation is imported js The variable name of the file is the same as html The variable names in the file have the same name , Then we can use as To change the imported file name .
When there are many variables to export , We can use *as To receive
The third import   Separate import , Add... Directly in front of the object or method export, Introduction is the same use import
Two . Anonymous export export
The first unified export , You can assign variable names at will , Unlike named import , You don't need curly braces , We must change script Of type type :module,, In unified export, you can also use as Change the variable name , Be sure to use the changed name when importing , As shown in the figure
The second kind of separate export
The export method is also abbreviated as follows , At a certain time value In the same case, it can be abbreviated
原网站

版权声明
本文为[sl105105]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207260840519462.html