假设我有一个扩展CommonComponent的HealthBar组件,我想访问baseComponent中的公共事件服务。
export class CommonComponent {
constructor(private eventService:EventService){}
/*
broadcast (eventName, eventObj){
let broadcastStr = this.name + " broadcast " + eventName;
this.log(broadcastStr, eventObj)
this.eventService.broadcast(eventName, eventObj );
}
*/
public broadcast = function(eventName, eventObj){
this.eventService.broadcast(eventName, eventObj );
}
healthBar可以访问旧的" public broadcast = function"但不是新注释掉的broadcast()语法。我以为他们是一回事,不是吗?为什么广告()不公开给儿童组件?