可以尝试使用colDef来代替colSpan,以下是一个可能的
// 定义表格列 const columnDefs = [ { headerName: 'Athlete', field: 'athlete', width: 150, cellStyle: {'font-weight': 'bold'} }, { headerName: 'Age', field: 'age', width: 90, cellStyle: {'text-align': 'center'} }, { headerName: 'Country', field: 'country', width: 120 }, { headerName: 'Year', field: 'year', width: 90 }, { headerName: 'Date', field: 'date', width: 145 }, { headerName: 'Sport', field: 'sport', width: 120 }, { headerName: 'Gold', field: 'gold', width: 100 }, { headerName: 'Silver', field: 'silver', width: 100 }, { headerName: 'Bronze', field: 'bronze', width: 100 }, { headerName: 'Total', field: 'total', width: 100 }, ];
// 定义表格数据 const rowData = [ { athlete: 'Michael Phelps', age: 23, country: 'United States', year: 2008, date: '24/08/2008', sport: 'Swimming', gold: 8, silver: 0, bronze: 0, total: 8 }, { athlete: 'Michael Phelps', age: 19, country: 'United States', year: 2004, date: '29/08/2004', sport: 'Swimming', gold: 6, silver: 0, bronze: 2, total: 8 }, { athlete: 'Michael Phelps', age: 27, country: 'United States', year: 2012, date: '12/08/2012', sport: 'Swimming', gold: 4, silver: 2, bronze: 0, total: 6 }, { athlete: 'Natalie Coughlin', age: 25, country: 'United States', year: 2008, date: '24/08/2008', sport: 'Swimming', gold: 1, silver: 2, bronze: 3, total: 6 }, { athlete: 'Aleksey Nemov', age: 24, country: 'Russia', year: 2000, date: '01/10/2000', sport: 'Gymnastics', gold: 2, silver: 1, bronze: 3, total: 6 }, { athlete: