Angular 4扩展并实现
发布时间:2020-12-17 09:41:18 所属栏目:安全 来源:网络整理
导读:我有一个类Hero需要扩展GoogleCharts类.我还需要实现OnInit来从params获取一些数据. 我怎样才能做到这一点? 像这样: export class Hero extends GoogleCharts implements OnInit {... 如果GoogleCharts已经实现了OnInit,你应该调用super.ngOnInit();在你的
我有一个类Hero需要扩展GoogleCharts类.我还需要实现OnInit来从params获取一些数据.
我怎样才能做到这一点?
像这样:
export class Hero extends GoogleCharts implements OnInit {... 如果GoogleCharts已经实现了OnInit,你应该调用super.ngOnInit();在你的ngOnInit方法中做其他事情之前. 像这样: interface OnInit { ngOnInit: () => void; } class GoogleCharts implements OnInit{ ngOnInit() { //does some stuff here } } class Hero extends GoogleCharts implements OnInit{ ngOnInit() { super.ngOnInit(); //do my stuff here } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |