当前位置:网站首页>ES6 module import / export summary
ES6 module import / export summary
2022-06-13 08:42:00 【huangxunlove】
ES6 There are three types of module import and export :
- Default import and default export
- On demand import and export
- Directly import and execute the code in the module
1、 Default import and default export
Default export Syntax :export default Default exported members
let n1 = 10
let n2 = 20
function show()
export default {
n1,
show
}
Default import Syntax :import Receiving name from ‘ Module identifier ’
import m1 from './01_m1.js'
matters needing attention : Only one use is allowed export default
2、 On demand import and export
On demand export Syntax :export Members exported on demand
export let s1 = 'aaa'
export function say(){
}
export default {
a:20
}
On demand import Syntax : import {s1} from ‘ Module identifier ’
import {
s1, say } from './03_m1.js'
matters needing attention :
- Multiple on-demand exports can be used in each module
- The name of the member imported on demand must be consistent with the name exported on demand
- On demand import , have access to as Keyword to rename
- On demand import can be used with default import
//info The output is an object , Is an object within the default export
import info, {
s1 as str1, say } from './03_m1.js'
Directly import and execute the code in the module
// The current file module is 05_m3.js
// Execute a... In the current module for Cyclic operation
for (let i=0;i<3;i++){
console.log(i)
}
-----------------------------------------
// Import and execute module code directly , You don't need to get external shared members of the module
import './05_m3.js'
边栏推荐
- 京东商品详情接口,京东详情页接口,宝贝详情页接口,商品属性接口,商品信息查询,商品详细信息接口,h5详情,京东APP详情,京东api接口,京东历史价格数据接口代码对接分享
- VI editor
- Buuctf web (V)
- Using KVM to create three virtual machines that can communicate with local area network
- centos 安装mysql及设置远程访问
- Notes on MySQL transaction not automatically submitting
- 情绪处理技巧
- MySQL sorts according to the specified order of the specified fields
- 2021-04-16
- On the use of regular expressions (bracket problem)
猜你喜欢
MySQL parsing serialized fields
MySQL sorts according to the specified order of the specified fields
Document contains question type
centos 安装mysql及设置远程访问
On the use of regular expressions (bracket problem)
redis. exceptions. ConnectionError: Error 111 connecting to 172.16.8.128:6379. Connection refused.
0.一些自己初学Solidworks的疑惑
Shellshock Attack Lab
2021-04-16
Form exercise 2
随机推荐
HCIP_ MGRE comprehensive experiment
抖音关键词搜索列表接口,超详细的接口对接步骤
Container concept and cloud native
Differences and uses among cookies, localstorage, sessionstorage, and application caching
PHP isset() method ignores data error handling caused by null parameter value
How app inventor accesses resource files in assets directory
Differences among let, VaR and const when JS declares variables
CentOS installing MySQL and setting up remote access
Centering problem - the width and height of child elements are known
JS wrapper object
When submitting the laravel admin form and using the required verification, an error is reported when the value is 0
2020-12-28
Buuctf web (VI)
Dest0g3 520迎新赛
HCIP_ Static experiment
情绪处理技巧
Input prohibit copy and paste
Penetration problem (main directory, password explosion, database uploading Trojan horse)
Logstash failed to create queue
A solution to create a new EXCEL workbook on win10 computer and change the suffix to xlsm (normally it should be xlsx)