当前位置:网站首页>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

边栏推荐
- High performance parallel programming and optimization | lesson 02 homework at home
- Descriptive analysis of data distribution characteristics (data exploration)
- APScheduler如何设置任务不并发(即第一个任务执行完再执行下一个)?
- 如何判断数组中是否含有某个元素
- [excel] PivotChart
- My NVIDIA developer journey - optimizing graphics card performance
- Online shrimp music will be closed in January next year. Netizens call No
- 光模塊字母含義及參數簡稱大全
- 一键过滤选择百度网盘文件
- VB. Net calls ffmpeg to simply process video (class Library-6)
猜你喜欢

High performance parallel programming and optimization | lesson 02 homework at home
![[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk](/img/b9/cf4db4f8a5d2ef3fb344258f0e30f5.jpg)
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk

Uninstall Google drive hard drive - you must exit the program to uninstall

2022 R2 mobile pressure vessel filling retraining question bank and answers

How to solve the component conflicts caused by scrollbars in GridView

What is MQ?

Leetcode question brushing record | 206_ Reverse linked list

JS扁平化数形结构的数组
![[excel] PivotChart](/img/45/be87e4428a1d8ef66ef34a63d12fd4.png)
[excel] PivotChart

Tf/pytorch/cafe-cv/nlp/ audio - practical demonstration of full ecosystem CPU deployment - Intel openvino tool suite course summary (Part 2)
随机推荐
BUU-Crypto-[HDCTF2019]basic rsa
ES6 模块化
Arc135 C (the proof is not very clear)
Detectron:训练自己的数据集——将自己的数据格式转换成COCO格式
C language simple student management system (including source code)
我的NVIDIA开发者之旅——优化显卡性能
[wechat applet] template and configuration (wxml, wxss, global and page configuration, network data request)
配置交叉编译工具链和环境变量
[microservice] Nacos cluster building and loading file configuration
体验碎周报第 102 期(2022.7.4)
Viewing and using binary log of MySQL
JS string splicing enhancement
Qt发布多语言国际化翻译
HMS v1.0 appointment. PHP editid parameter SQL injection vulnerability (cve-2022-25491)
How to clone objects
A little understanding of GSLB (global server load balance) technology
Tf/pytorch/cafe-cv/nlp/ audio - practical demonstration of full ecosystem CPU deployment - Intel openvino tool suite course summary (Part 2)
LayoutManager布局管理器:FlowLayout、BorderLayout、GridLayout、GridBagLayout、CardLayout、BoxLayout
Thinkphp6.0 middleware with limited access frequency think throttle
Talk about the SQL server version of DTM sub transaction barrier function