首页 > 其他 > 详细

ES6初识- Class

时间:2017-11-26 23:41:38      阅读:228      评论:0      收藏:0      [点我收藏+]
{
//基本定义和生成实例
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();
}

ES6初识- Class

原文:http://www.cnblogs.com/fuGuy/p/7900793.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!