当前位置:网站首页>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"
}
边栏推荐
- Playful palette: an interactive parametric color mixer for artists
- IBM WebSphere channel connectivity setup and testing
- 自定义JvxeTable的按钮及备注下$set的用法
- What is certificate transparency CT? How to query CT logs certificate logs?
- 备忘一下es6的export/import和类继承的用法
- Pytoch learning (II)
- Time complexity analysis
- Shenzhen CPDA Data Analyst Certification in July 2022
- FDA ESG regulation: digital certificate must be used to ensure communication security
- Cmake tutorial series -04- compiling related functions
猜你喜欢

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

Differences among digicert, SECTIONO and globalsign code signing certificates

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

Summary of knowledge points about eigenvalues and eigenvectors of matrices in Chapter 5 of Linear Algebra (Jeff's self perception)

2.8 【 weight of complete binary tree 】

Detailed explanation of minimum stack

What should academic presentation /ppt do?

Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)

GTK interface programming (I): Environment Construction

Mysql表数据比较大情况下怎么修改添加字段
随机推荐
The Oracle main program is deleted, but the data is on another hard disk. Can I import the data again?
JMeter obtains cookies across thread groups or JMeter thread groups share cookies
oracle怎么设置密码复杂度及超时退出的功能
Threejs mirror case reflector create mirror + house construction + small ball movement
Distributed file system fastdfs
Série de tutoriels cmake - 02 - génération de binaires à l'aide du Code cmake
Steam elements hidden in science and Technology Education
2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...
How do I enable assembly binding logging- How can I enable Assembly binding logging?
How can redis+aop customize annotations to achieve flow restriction
Seven common errors of SSL certificate and their solutions
Cmake tutorial series -04- compiling related functions
多卡服务器使用
Global and Chinese market of wind energy equipment logistics 2022-2028: Research Report on technology, participants, trends, market size and share
unity的text首列有标点符号咋办
Pytorch学习(二)
Redis+AOP怎么自定义注解实现限流
How to set password complexity and timeout exit function in Oracle
Sitelock nine FAQs
CMake教程系列-03-依赖管理