当前位置:网站首页>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"
}
边栏推荐
- c#控制台格式化代码
- Global and Chinese market of relay lens 2022-2028: Research Report on technology, participants, trends, market size and share
- Unity timeline data binding
- Linear algebra Chapter 4 Summary of knowledge points of linear equations (Jeff's self perception)
- 2. < tag dynamic programming and 0-1 knapsack problem > lt.416 Split equal sum subset + lt.1049 Weight of the last stone II
- Unity3d ugui force refresh of layout components
- CMake教程系列-02-使用cmake代码生成二进制
- [Postgres] Postgres database migration
- Unity3D UGUI强制刷新Layout(布局)组件
- Playful palette: an interactive parametric color mixer for artists
猜你喜欢

Sitelock nine FAQs

在php中字符串的概念是什么

Intel hex, Motorola S-Record format detailed analysis

Raki's notes on reading paper: Leveraging type descriptions for zero shot named entity recognition and classification
![[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation](/img/c3/f9d6399c931a006ca295bb1e3ac427.png)
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation

Two methods of SSL certificate format conversion

JMeter obtains cookies across thread groups or JMeter thread groups share cookies

中断操作:AbortController学习笔记
![[dry goods sharing] the latest WHQL logo certification application process](/img/c3/37277572c70b0af944e594f0965a6c.png)
[dry goods sharing] the latest WHQL logo certification application process

Playful palette: an interactive parametric color mixer for artists
随机推荐
SQLite use
Interrupt operation: abortcontroller learning notes
Time complexity analysis
Global and Chinese markets of liquid optical waveguides 2022-2028: Research Report on technology, participants, trends, market size and share
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation
How to set password complexity and timeout exit function in Oracle
Three solutions to forced hibernation of corporate computers
IDEA 远程调试 Remote JVM Debug
模板参数包和函数参数包
How to use vant to realize data paging and drop-down loading
Global and Chinese market of mobile commerce solutions 2022-2028: Research Report on technology, participants, trends, market size and share
原生JS怎么生成九宫格
Série de tutoriels cmake - 02 - génération de binaires à l'aide du Code cmake
学术汇报(academic presentation)/PPT应该怎么做?
Welfare lottery | what are the highlights of open source enterprise monitoring zabbix6.0
Distributed file system fastdfs
[on] [DSTG] dynamic spatiotemporalgraph revolutionary neural networks for traffic data impact
Creating exquisite skills in maker Education
002 color classification
How to use redis to realize the like function