我有一个类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 } }