当前位置:网站首页>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使用别名。
岁月有加,并未垂老。理想丢弃,方堕暮年。
边栏推荐
- PHP 使用endroid/qrcode 二维码生成, GD库生成分享海报
- SQL note 2 [MySQL]
- Cmake tutorial (I)
- IDC: Alibaba cloud ranks first in the market share of China's data governance platform in 2021
- scrapy保存数据到excel:利用openpyxl创建多张表,设置Excel行数限制
- [matlab] function definition and use
- 百度知道爬虫,根据问题id,线索id,评论id获取评论下面的对话
- Count the number of arrays with pointers
- 这样学习二叉树
- What are the virtual machine software? What are their respective roles?
猜你喜欢
![SQL note 2 [MySQL]](/img/a4/f711173ce731d95860746e309b7d74.jpg)
SQL note 2 [MySQL]

Implementation of dynamic timer for quartz

Stm32f407 ------- RTC real time clock

stm32F407-------LCD

Chapter II Classic synchronous exercises
![[stm32 HAL库] RTC和BKP驱动](/img/72/c2c46377d0a2a5a032802640ca0201.png)
[stm32 HAL库] RTC和BKP驱动
![[matlab] function definition and use](/img/43/a7970ca8e075151277f7773434f7db.png)
[matlab] function definition and use

PHP 使用endroid/qrcode 二维码生成, GD库生成分享海报

Machine learning 6-decision tree
![[software analysis] iterative explanation of software analysis, design and modeling](/img/37/1163fec464aed365d1ea04e63a0c90.png)
[software analysis] iterative explanation of software analysis, design and modeling
随机推荐
Rongyun communication solution solves the pain points of enterprise communication
How to solve the database type error in the operation of the servert project?
[state machine design] Moore, Mealy state machine, three-stage, two-stage and one-stage state machine writing specification
stm32F407-------电容触摸按键
[matlab] function definition and use
Yyds dry goods inventory building knowledge map from scratch with neo4j (I)
Yes, use local_ setup. Bash or setup bash
Oil monkey script learning
pymysql.Error 获取错误码与具体错误信息
stm32F407-------NVIC中断优先级管理
Do you know all the wonderful functions of the vlookup function?
What will be done after digital IC Verification?
MSCI 2022 market classification assessment
Stm32f407 ------- RTC real time clock
[stm32 Hal library] RTC and BKP drives
Scrapy uses xlwt to implement the exporter that exports data in Excel format
Advice to friends
O & M troubleshooting - use hcache plug-in to troubleshoot excessive buffer/cache occupancy
Behaviortree in ros2
[stm32 HAL库] RTC和BKP驱动