我有一个使用AG-Grid渲染表的准系统React组件。但是我遇到了一个问题,高度/顶部会自动增加,而没有任何输入。
import { AgGridReact } from "ag-grid-react";
import "ag-grid-community/dist/styles/ag-grid.css";
import "ag-grid-community/dist/styles/ag-theme-material.css";
render () {
const colDef = [{
headerName: "Make", field: "make",
}, {
headerName: "Model", field: "model",
}, {
headerName: "Price", field: "price",
}];
const dataRows = [{
make: "Toyota", model: "Celica", price: 35000,
}, {
make: "Ford", model: "Mondeo", price: 32000,
}, {
make: "Porsche", model: "Boxter", price: 72000,
}];
return (
<div className={`ag-theme-material`}>
<AgGridReact
columnDefs={colDef}
rowData={dataRows}
/>
</div>
)
}
我检查了变化的元素。看来Top
在此div上一直在自动增加:
<div class="ag-floating-bottom" role="presentation" style="height: 0px; top: 422px;">
和Height
,我不知道为什么:
<div class="ag-body ag-row-no-animation" role="presentation" style="height: 516px; top: 56px;">
请注意,我尝试了其他主题的ag-grid版本,并遇到了相同的问题。