当前位置:网站首页>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
边栏推荐
- JS扁平化数形结构的数组
- How to determine whether an array contains an element
- What is MQ?
- Use of hutool Pinyin tool
- FRP intranet penetration, reverse proxy
- JS string splicing
- [high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk
- Experience weekly report no. 102 (July 4, 2022)
- LC周赛300
- Viewing and using binary log of MySQL
猜你喜欢
VB. Net GIF (making and disassembling - optimizing code, class library - 5)
Arc135 C (the proof is not very clear)
509. 斐波那契数、爬楼梯所有路径、爬楼梯最小花费
C语言练习题(递归)
[excel] PivotChart
What are the reasons for the frequent high CPU of ECS?
BUU-Real-[PHP]XXE
我的NVIDIA开发者之旅——优化显卡性能
Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor
配置交叉编译工具链和环境变量
随机推荐
Talk about the SQL server version of DTM sub transaction barrier function
js arguments参数使用和详解
BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述
卸载Google Drive 硬盘-必须退出程序才能卸载
Basic concept of bus
How much computing power does transformer have
总线的基本概念
VB.net 调用FFmpeg简单处理视频(类库——6)
光模塊字母含義及參數簡稱大全
fastjson
HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
Supplement the JS of a video website to decrypt the video
【雕爷学编程】Arduino动手做(105)---压电陶瓷振动模块
Steady! Huawei micro certification Huawei cloud computing service practice is stable!
Solar insect killing system based on single chip microcomputer
JS flattened array of number shape structure
LayoutManager布局管理器:FlowLayout、BorderLayout、GridLayout、GridBagLayout、CardLayout、BoxLayout
The difference between PX EM rem
How to implement lazy loading in El select (with search function)
input显示当前选择的图片