perfect-scrollbar滚动到元素不起作用

时间:2019-10-03 14:34:06

标签: javascript angular typescript angular8 perfect-scrollbar

我正在使用perfect scrollbar。但是不能使用scrollToElement属性。 传递元素时,它会引发打字稿错误 "DOMException: Failed to execute 'querySelector' on 'Document': "

import PerfectScrollbar from 'perfect-scrollbar';

 const firstElementWithError1 = document.querySelector('.ng-invalid');
        const ps = new PerfectScrollbar(firstElementWithError1.innerHTML);
        ps.update();

我的html代码如下:

<form class="form-center" [formGroup]="basicDetails" #employeebasicDetails="ngForm">


      <table cellspacing="0" class="w-100">
        <tr>
          <td colspan="2" >
            <table  class="w-100">
              <tr>
                <td class="lastInput">
                  <mat-form-field appearance="outline" class="input-pb-0">
                    <mat-label>Last Name </mat-label>
                    <input matInput formControlName="lastname" [ngModel]="LastName"  required maxlength="50" >
                    <mat-error *ngIf="!basicDetails.controls['lastname'].valid && basicDetails.controls['lastname'].touched">
                      last name required
                    </mat-error>
                  </mat-form-field>
                </td>
                </tr>
            </table>
          </td>
        </tr>

      </table>
    </div>
  </div>
</form>

0 个答案:

没有答案