Reactjs 如何在React中使用AG网格?我得到构建错误
以下是组件文件:Reactjs 如何在React中使用AG网格?我得到构建错误,reactjs,ag-grid,spfx,Reactjs,Ag Grid,Spfx,以下是组件文件: import { AgGridReact } from '@ag-grid-community/react'; import {AllCommunityModules} from '@ag-grid-community/all-modules'; import '@ag-grid-community/all-modules/dist/styles/ag-grid.css'; import '@ag-grid-community/all-modules/dist/styles/a
import { AgGridReact } from '@ag-grid-community/react';
import {AllCommunityModules} from '@ag-grid-community/all-modules';
import '@ag-grid-community/all-modules/dist/styles/ag-grid.css';
import '@ag-grid-community/all-modules/dist/styles/ag-theme-balham.css';
export default class FormGrid extends React.Component<IFormGridProps,IFormGridState> {
constructor(props: IFormGridProps, state: IFormGridState){
super(props);
this.state = {
columnDefs: [
{ headerName: "Make", field: "make" },
{ headerName: "Model", field: "model" },
{ headerName: "Price", field: "price" }],
rowData: [
{ make: "Toyota", model: "Celica", price: 35000 },
{ make: "Ford", model: "Mondeo", price: 32000 },
{ make: "Porsche", model: "Boxter", price: 72000 }]
}
}
public render(): React.ReactElement<IFormGridProps> {
return (
<div className={ styles.formGrid }>
<div className={ styles.container }>
<div className={ styles.row }>
<div className="ag-theme-balham" style={ {height: '200px', width: '600px'} }>
<AgGridReact
columnDefs={this.state.columnDefs}
rowData={this.state.rowData}
modules={AllCommunityModules}>
</AgGridReact>
</div>
</div>
</div>
</div>
);
}
}
我不明白为什么会出错。请帮帮我 确保已安装“@ag grid community/all modules”软件包 我尝试了你的代码,它编译得很好,但我必须安装上面的软件包。你也可以粘贴你的进口吗 其他注意事项/提示:
- 在第2行中,您只能将
作为React类组件的参数传递(但这不会给您带来这样的错误)props
- 不需要为渲染方法添加类型
export interface IFormGridState{
columnDefs: any,
rowData: any
}