当前位置:网站首页>Note the use of export/import and class inheritance in ES6
Note the use of export/import and class inheritance in ES6
2022-06-30 02:53:00 【OK_ boom】
Just remember , I don't know if I have misunderstood
export default This default export , import You can import the name directly , Don't add... To the name {}
export Followed by a specific name ( Like the function name , Object name ), import When it comes to import Add braces {}
es6 Classes of also have inheritance extends Grammatical sugar , To call a parent class method super.xxx(), Call the parent class to build super()
Here is an example , a.js Is the code in the parent class :
class ParentClass{
sayHello(){
console.log("parent hello")
}
}
class ParentClass2 extends ParentClass{
sayHello(){
console.log("parent2 hello")
super.sayHello() // Calls a method of the parent class
}
}
export default{
ParentClass2,
name: 'ExpParentClass'
}
export const ParentClass3={
sayHello(){
console.log("ParentClass3 Const hello")
}
}
b.js quote a.js:
import {
ParentClass3} from './a.js'
import ExpParentClass from './a.js'
class Son extends ExpParentClass.ParentClass2{
sayHello(){
console.log("-------------------")
super.sayHello()
console.log("Son hello")
console.log("-------------------")
}
}
let p1=new ExpParentClass.ParentClass2()
p1.sayHello()
let son=new Son()
son.sayHello()
ParentClass3.sayHello()
This directory should have a name package.json, adopt npm init -y Command line generation , type To set up for module
{
"name": "study1",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
边栏推荐
- Study diary: February 15, 2022
- The rigorous judgment of ID number is accurate to the last place in the team
- Three solutions to forced hibernation of corporate computers
- Global and Chinese market of Kanban software 2022-2028: Research Report on technology, participants, trends, market size and share
- Summary of interview and Employment Questions
- IDEA 远程调试 Remote JVM Debug
- Xunwei enzhipu ITop - imx6 Development Platform
- Unity timeline data binding
- How vscode debugs into standard library files / third-party package source code
- 原生JS怎么生成九宫格
猜你喜欢

可视化HTA窗体设计器-HtaMaker 界面介绍及使用方法,下载 | HTA VBS可视化脚本编写

FDA mail security solution

Raki's notes on reading paper: discontinuous named entity recognition as maximum clique discovery

Steam elements hidden in science and Technology Education

oracle怎么设置密码复杂度及超时退出的功能

Raki's notes on reading paper: named entity recognition as dependency parsing

中断操作:AbortController学习笔记

CMake教程系列-02-使用cmake代碼生成二進制

Five cheapest wildcard SSL certificate brands

Enlightenment from the revocation of Russian digital certificate by mainstream CA: upgrade the SSL certificate of state secret algorithm to help China's network security to be autonomous and controlla
随机推荐
(图论) 连通分量(模板) + 强连通分量(模板)
Intel-Hex , Motorola S-Record 格式详细解析
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation
2.< tag-动态规划和0-1背包问题>lt.416. 分割等和子集 + lt.1049. 最后一块石头的重量 II
Five cheapest wildcard SSL certificate brands
What is an X.509 certificate? 10. 509 certificate working principle and application?
How to modify and add fields when MySQL table data is large
自定义JvxeTable的按钮及备注下$set的用法
备忘一下es6的export/import和类继承的用法
Global and Chinese market for defense network security 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of ERP software for garment and textile industries 2022-2028: Research Report on technology, participants, trends, market size and share
SQLite use
学术汇报(academic presentation)/PPT应该怎么做?
Differences among digicert, SECTIONO and globalsign code signing certificates
RAII内存管理
HTA introductory basic tutorial | GUI interface of vbs script HTA concise tutorial, with complete course and interface beautification
Cmake tutorial series -02- generating binaries using cmake code
LeetCode 3. Longest substring without duplicate characters
Xunwei NXP itop-imx6 development platform
c#控制台格式化代码