在我的组件类 (HeaderComponent) 中,每次单击 changeBannerArrow() 和 changeBannerImg() 这两个函数时,我都想访问 changeBtnColorBg 函数
这些函数在 HTML 端的 onclick 事件上触发
export class HeaderComponent implements OnInit {
imgTotal = 3;
currentImg = 0;
imgHdr = [];
changeBannerImg(imgSelect){
/* some code here */
changeBtnColorBg(this.currentImg, imgSelect);
}
changeBannerArrow(imgSelect){
from = this.currentImg;
/* some code here*/
to = this.currentImg;
changeBtnColorBg(from, to);
}
changeBtnColorBg(from, to){
this.imgHdr[from].selected = false; //change back to transparent
this.imgHdr[to].selected = true; //change bg color
}
}
但是这种结构会产生错误
HeaderComponent.html:15 错误 ReferenceError: changeBtnColorBg 未定义
有人可以帮忙吗?我是新手