ionic开发细节三则

202

获取ElementRef要加上{ read: ElementRef }

  @ViewChild("scrollContainer", { read: ElementRef }) scrollContainer: ElementRef;

参考链接:https://segmentfault.com/a/1190000008695459

 

控制<ion-scroll>可使用以下方法:

  scrollToBottom() {
    this.scrollContainer.nativeElement.children[0].scrollTop = this.scrollContainer.nativeElement.children[0].scrollHeight;
  }

 

检测组件更新使用:

changeDetectorRef.detectChanges();

之前使用markForCheck,必须配合定时器一直检查才行,具体原因待探究。

留下一个答复

Please enter your comment!
Please enter your name here