2

我在我的 angular4 应用程序中使用 angular2-perfect-scrollbar。我初始化了它,它工作正常,但是当我从列表中删除一个项目时,滚动条没有更新并溢出实际内容

我尝试按照此处的描述对其进行更新 How to call update() method of in Angular 2 Perfect Scrollbar wrapper? 但它没有用。

我在 tbody 元素中使用了完美的滚动条指令(显示属性设置为阻止。)但这不应该是问题。

            <tbody #tableContent *ngIf ="users" [perfect-scrollbar]>

它包含在我的模块中

import { PerfectScrollbarConfigInterface, PerfectScrollbarModule } from 'angular2-perfect-scrollbar';

@NgModule({ imports: [ SharedLibsModule, PerfectScrollbarModule.forRoot(PERFECT_SCROLLBAR_CONFIG) ],

我的组件包含这样的容器:

    @ViewChild('tableContent') tableContent: PerfectScrollbarDirective;

我这样称呼更新:

private onSuccess(data, headers) {
    this.tableContent.update();
}

任何帮助将不胜感激。

@Edit:滚动条已更新,如果我尝试在表格上滚动或调整浏览器窗口的大小,它可以正常工作。

4

1 回答 1

3

如果我像这样阅读 PerfectScrollbarDirective,它工作正常:

@ViewChild('tableContent', {read: PerfectScrollbarDirective}) tableContent: PerfectScrollbarDirective;

然后调用this.tableContent.update();

于 2018-09-25T06:27:15.977 回答