【发布时间】:2019-03-17 20:06:39
【问题描述】:
我的 app.component.html:
{{bla()}}
我的 app.component.ts:
import {Component, OnInit, AfterViewInit} from '@angular/core';
@Component({
selector: 'idr-app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements AfterViewInit {
constructor() {}
ngAfterViewInit() {}
bla(){
console.log(77777);
}
}
我的 app.module.ts:
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
],
providers: [
],
bootstrap: [AppComponent],
})
export class AppModule {
}
在控制台我看到这种情况:
app.component.ts:13 77777
app.component.ts:13 77777
core.js:3688 Angular is running in the development mode. Call enableProdMode() to enable the production mode.
app.component.ts:13 77777
app.component.ts:13 77777
如果我在子组件中使用类似 {{bla()}} 的东西,77777 会显示更多次
那么有人知道为什么它会重绘几次吗?
【问题讨论】:
标签: angular angular5 angular2-template redraw