问题

在一个component里面,如果有多个mat-table matSort,怎么使用ViewChild

方案

使用ViewChild的时候,需要使用id

@ViewChild('sort1') sort1: MatSort;

在页面中,需要

    <mat-table #table [dataSource]="dataSource" #sort1="matSort" matSort>