当前位置:网站首页>ES6模块
ES6模块
2022-06-28 23:43:00 【Run Coder】
ES6模块
- ES6模块语法
| 代码 | 含义 |
|---|---|
| export const ninja = ‘Yoshi’; | 导出变量 |
| export function ninja(){}; | 导出函数 |
| export class Ninja{}; | 导出类 |
| export default class Ninja{}; | 导出默认类 |
| export default function Ninja(){}; | 导出默认函数 |
| const ninja = ‘Yoshi’; function compare(){}; export {ninja,compare}; | 导出存在的变量 |
| export{ninja as samurai,compare}; | 使用别名导出变量 |
| import Ninja from ‘Ninja.js’; | 导入默认导出 |
| import {ninja,Ninja} from ‘Ninja.js’; | 导入命名导出 |
| import * as Ninja from ‘Ninja.js;’ | 导入模块中声明的全部导入内容 |
| import {ninja as Ninja} from ‘Ninja.js’; | 通过别名导入模块中声明的全部导出内容 |
- ES6模块的特点。
- ES6模块基于文件,一个文件是一个模块
- 通过关键字export导出标识符,在其他模块中可以引用这些标识符。
- 在其他模块中可以通过关键字import导入标识符。
- 模块可以使用默认导出,通过一个export导出整个模块。
- export与import都可以通过关键字as使用别名。
岁月有加,并未垂老。理想丢弃,方堕暮年。
边栏推荐
- What will be done after digital IC Verification?
- Yyds dry goods inventory building knowledge map from scratch with neo4j (I)
- Hesitating root sound
- Have you ever met a fake interview in a job interview? How to avoid?
- Scrapy使用xlwt实现将数据以Excel格式导出的Exporter
- [Electronic Experiment 2] simple electronic doorbell
- The second session of question swiping and clock out activity -- solving the switching problem with recursion as the background (2)
- stm32F407-------外部中断
- [word Tutorial Series Part 1] how to remove arrows in word tables
- 入行数字IC验证后会做些什么?
猜你喜欢

Matlab learning notes (6) upsample function and downsample function of MATLAB

The second session of question swiping and clock out activity -- solving the switching problem with recursion as the background (III)

Online yaml to JSON tool

Analysis of CSRF Cross Site Request Forgery vulnerability

【OpenCV】—线性滤波:方框滤波、均值滤波、高斯滤波

Use conditional breakpoints in vscode (based on GDB)

Behaviortree in ros2

Machine learning 4-dimension reduction technology

Blue Bridge Cup top ten common heaven level skill - breath of water The type of one recursion

Have you ever met a fake interview in a job interview? How to avoid?
随机推荐
"Five considerations" for safe use of the Internet
Yyds dry goods count 【 vs code work record III 】 set vs code format
fio的IO重放功能
Huawei's level 22 experts have worked hard for ten years to complete the advanced practical document of cloud native service grid. 6
华为22级专家十年心血终成云原生服务网格进阶实战文档,是真的6
Three communication skills in software testing
Picture 64base transcoding and decoding
Matlab learning notes (6) upsample function and downsample function of MATLAB
Machine learning 6-decision tree
想问问,股票开账户如何优惠开户?网上开户安全么?
pymysql. Error get error code and specific error information
【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
Advice to friends
PHP 使用endroid/qrcode 二维码生成, GD库生成分享海报
Do you know all the wonderful functions of the vlookup function?
[matlab] function definition and use
Windows10 phpstudy installing redis extension
Be on the list again! Know that Chuangyu was selected as one of the top 50 competitive enterprises in China's network security industry in 2022
从SQL注入绕过最新安全狗WAF中学习fuzz
[software analysis] iterative explanation of software analysis, design and modeling