ElemeFE / element-angular

Element for Angular
https://element-angular.faas.ele.me
MIT License
530 stars 121 forks source link

carousel组件不能自动轮播 #134

Closed chaikd closed 6 years ago

chaikd commented 6 years ago

Issue Type:

Version & Environment:
"@angular/animations": "^5.2.0", "@angular/common": "^5.2.0", "@angular/compiler": "^5.2.0", "@angular/core": "^5.2.0", "@angular/forms": "^5.2.0", "@angular/http": "^5.2.0", "@angular/platform-browser": "^5.2.0", "@angular/platform-browser-dynamic": "^5.2.0", "@angular/router": "^5.2.0", "core-js": "^2.4.1", "element-angular": "^0.7.6",

Description: 如题,发现可能是触发的钩子函数的原因,不明白为什么ngAfterContentChecked一直在执行;

将carousel模块的ngAfterContentChecked钩子函数改为ngAfterViewInit;

ngAfterContentChecked

在组件每次检查内容放生变更时调用。在ngAfterContentInit和每次ngDoCheck之后调用

ngAfterViewInit

在组件相应的视图初始化之后调用,第一次ngAfterContentChecked之后调用,只调用一次

ngDoCheck

在组件定义的属性或方法变更时调用(用于脏值之检测,非常耗性能,因为会把所有的属性和方法都检测一遍),会在ngOnChanges()和ngOnInit()之后;

不知道对不对,但我是这样改了用的,目前没发现有什么问题;