import { Card, Icon } from 'antd';
import React from 'react';
class InfoData extends React.Component {
// 属性只从构造器注入
// alias
// name <=> title
// html_url <=> rel
// description是描述
// stargazers_count <=> stars
// created_at <=> created
// updated_at <=> updated
// pushed_at <=> pushed
constructor(
title, language,
forks, stars,
rel, description,
created, updated, pushed) {
super();
this.title = title;
this.language = language;
this.forks = forks;
this.stars = stars;
this.rel = rel;
this.description = description;
this.created = created;
this.updated = updated;
this.pushed = pushed;
}
set created(created) { this._created = created; }
get created() {
return `创建时间:${this._created}`;
}
set updated(updated) { this._updated = updated; }
get updated() {
return `更新时间:${this._updated}`;
}
set pushed(pushed) { this._pushed = pushed; }
get pushed() {
return `上次更新:${this._updated - this._pushed} years ago`;
}
HolderView() {
const rightpart = (
<div>
{this.language}
<Icon type={'star'} />{this.stars}
<Icon type={'code'} />{this.forks}
</div>
);
return (
<Card
title={this.title} extra={rightpart}
>
<p>{this.description}</p>
<p>{this.created}</p>
<p>{this.updated}</p>
<p>{this.pushed}</p>
</Card>
);
}
}
export default InfoData;
es6 class定义 属性钩子
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 在掘金的分享文章当中看到了关于es6 const 和 let变量声明是否提升的文章,学到了很多。 原文链接stac...