当前位置:网站首页>ES6 modularization
ES6 modularization
2022-07-04 05:52:00 【Yu'an_ ZhangDe】
ES6 modularization brief introduction
ES6 Modular specification yes Browser side And Server side General modular development specification . Its appearance greatly reduces the modular learning cost of front-end developers , Developers don't need to learn any more AMD(AMD yes !!! XD)、CMD or CommonJS Isomodular specification .
ES6 It is defined in the modular specification :
- Every js File is a separate module
- Import other module members to use import keyword
- Shared module members use export keyword
stay node.js Experience ES6 modularization
- Make sure that... Is installed v14.15.1 Or later node.js
- stay package.json Add... To the root node of "type": "module" node
The default is derived and The default import
Every js It can only be used once in the script export default , Otherwise, an error will be reported
// The default is derived
// Every js It can only be used once in the script export default , Otherwise, an error will be reported
let m1 = 10
let m2 = 20
let f1 = () =>{}
export default {
m1,
f1
}
// The default import
// Be sure to write the file suffix in the path
import i1 from './01. The default is derived .js'
console.log(i1)
Export... On demand and Import on demand
// Export... On demand
export let s1 = 'aaa'
export let s2 = 'ccc'
export const add = x => x+10
// Import on demand
// Pass on the discovery and current js The variable name of the script conflicts , We can use as change name , Only in the present js Valid in script
import {s1 as ss,s2,add} from './03. Export... On demand .js'
let s1 = 10
console.log(ss)
console.log(s2)
console.log(s1)
console.log(add(s1))
Direct import
Direct import will execute the imported js Script the program
边栏推荐
- Redis realizes ranking function
- buuctf-pwn write-ups (8)
- Arc135 C (the proof is not very clear)
- Kubernets first meeting
- Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
- Qt发布多语言国际化翻译
- Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
- ANSYS command
- fastjson
- BUU-Crypto-[HDCTF2019]basic rsa
猜你喜欢
APScheduler如何设置任务不并发(即第一个任务执行完再执行下一个)?
How to configure static IP for Kali virtual machine
Configure cross compilation tool chain and environment variables
配置交叉编译工具链和环境变量
C # character similarity comparison general class
Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
ansys命令
My NVIDIA developer journey - optimizing graphics card performance
How to expand all collapse panels
BUU-Reverse-easyre
随机推荐
Thinkphp6.0 middleware with limited access frequency think throttle
Kubernets first meeting
Leetcode 184 Employees with the highest wages in the Department (July 3, 2022)
el-select如何实现懒加载(带搜索功能)
Supplement the JS of a video website to decrypt the video
left_and_right_net可解释性设计
安装 Pytorch geometric
检漏继电器JY82-2P
如何判断数组中是否含有某个元素
Talk about the SQL server version of DTM sub transaction barrier function
Weekly summary (*63): about positive energy
My NVIDIA developer journey - optimizing graphics card performance
What is MQ?
Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
Halcon图片标定,使得后续图片处理过后变成与模板图片一样
Input displays the currently selected picture
BUU-Crypto-Cipher
19. Framebuffer application programming
VB.net 简单的处理图片,黑白(类库——7)
Arc135 a (time complexity analysis)