当前位置:网站首页>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"
}
边栏推荐
- (graph theory) connected component (template) + strongly connected component (template)
- Some configuration details about servlet initial development
- How long is the general term of the bank's financial products?
- C console format code
- JMeter obtains cookies across thread groups or JMeter thread groups share cookies
- How to prevent phishing emails? S/mime mail certificate
- 并发请求下如何防重复提交
- 怎么使用Vant实现数据分页和下拉加载
- Idea remote debugging remote JVM debug
- 2022护网行动在即,关于护网的那些事儿
猜你喜欢

LeetCode 3. Longest substring without duplicate characters

Implementation of Sanzi chess with C language

学术汇报(academic presentation)/PPT应该怎么做?

Mysql表数据比较大情况下怎么修改添加字段

重磅来袭--UE5的开源数字孪生解决方案

Raki's notes on reading paper: Leveraging type descriptions for zero shot named entity recognition and classification

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

Pytorch学习(二)

How to prevent phishing emails? S/mime mail certificate

2.8 【 weight of complete binary tree 】
随机推荐
C language pivot_ Invalid argument error resolution for root
Jvxetable增加自定义按钮
Pytoch learning (II)
c#控制台格式化代码
Template parameter package and function parameter package
Global and Chinese markets for light cargo conveyors 2022-2028: Research Report on technology, participants, trends, market size and share
Servlet面试题
2. < tag dynamic programming and 0-1 knapsack problem > lt.416 Split equal sum subset + lt.1049 Weight of the last stone II
Azure developer news flash list of events of developers in June
Unity3D UGUI强制刷新Layout(布局)组件
How to use redis to realize the like function
How to use vant to realize data paging and drop-down loading
Seven common errors of SSL certificate and their solutions
Interrupt operation: abortcontroller learning notes
并发请求下如何防重复提交
What kind of foreign exchange trading platform is regulated and safe?
How can redis+aop customize annotations to achieve flow restriction
Welfare lottery | what are the highlights of open source enterprise monitoring zabbix6.0
How does native JS generate Jiugong lattice
Global and Chinese markets for wireless security in LTE networks 2022-2028: Research Report on technology, participants, trends, market size and share