ES6初识- Class

{
//基本定义和生成实例
class Parent{
//构造函数
constructor(name='lisi'){
this.name=name;
}
//属性get,set
get longName(){
return 'china'+this.name;
}
set longName(value){
this.name=value;
}
 
 
}
class Child extends Parent{
constructor(name='Child'){
super(name);
this.type='child';
}
}
let parent=new Parent(name='zhangsan');
console.log('parent',parent);
let child =new Child();
console.log("child",child);
}
{
class Parent{
//构造函数
constructor(name='lisi'){
this.name=name;
}
//属性get,set
get longName(){
return 'china'+this.name;
}
set longName(value){
this.name=value;
}
static tell(){
console.log("tell");
}
 
}
Parent.type="test";
Parent.tell();
}
原文地址:https://www.cnblogs.com/fuGuy/p/7900793.html