gpt4 book ai didi

reactjs - ag-grid-react 无法正确渲染

转载 作者:行者123 更新时间:2023-12-03 13:33:10 26 4
gpt4 key购买 nike

按照文档中的示例: https://www.ag-grid.com/best-react-data-grid/index.php

创建新的 react 应用程序后(在不同的机器上尝试了几次)

create-react-app whatever

如果我应用样式表(ag-grid.css 和 theme-fresh.css),则呈现的所有内容都是页面上的灰线。任何其他组合都会呈现空白页面。删除 ag-grid.css 会渲染网格,但它到处都是困惑的。

最近有人在 React 中成功使用过这个吗?有人推荐一些不同的东西吗? (要求:分页、排序、过滤、可选择行)

谢谢:-)

import React, { Component } from 'react';
import {AgGridReact} from 'ag-grid-react';
import '../node_modules/ag-grid/dist/styles/ag-grid.css';
import '../node_modules/ag-grid/dist/styles/theme-fresh.css';

class App extends Component {
constructor(props) {
super(props);
this.state = {
columnDefs: [
{headerName: 'First Name', field: 'name' },
{headerName: 'Last Name', field: 'lname' }
],
rowData: [
{ name: 'Dave', lname: 'Smith' },
{ name: 'Tommy', lname: 'Smith' },
{ name: 'Lea', lname: 'Jones' }
]
}
}
render() {
return (
<div className="ag-fresh">
<AgGridReact
columnDefs={this.state.columnDefs}
rowData={this.state.rowData}
rowSelection="multiple"
enableColResize="true"
enableSorting="true"
enableFilter="true"
groupHeaders="true"
rowHeight="22"
debug="true"
/>
</div>
);
}
}

export default App;

最佳答案

外部网格需要高度:-(

文档没有显示这一点。不知道为什么网格没有最小默认高度,但确实没有。

关于reactjs - ag-grid-react 无法正确渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39608309/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com