来自Angular Tour of Heroes教程:https://angular.io/tutorial/toh-pt4
代码 :
getHeroes(): void {
this.heroes = this.heroService.getHeroes();
}
声明方法的这种语法是什么意思?
来自Angular Tour of Heroes教程:https://angular.io/tutorial/toh-pt4
代码 :
getHeroes(): void {
this.heroes = this.heroService.getHeroes();
}
声明方法的这种语法是什么意思?
1 回答
getHeroes 是方法的名称
: void 返回void(无)
{ 方法体的开头
this.heroes = this.heroService.getHeroes(); 方法的返回值'getHeroes'(来自heroService)被赋值给局部变量'heroes'
} 方法体的结尾